Files
michaelschiemer/src/Framework/OAuth/OAuthClient.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

128 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\OAuth;
use App\Framework\HttpClient\HttpClient;
use App\Framework\OAuth\ValueObjects\OAuthToken;
/**
* Generic OAuth Client
*
* Handles HTTP requests to OAuth providers using framework's HttpClient
*/
final readonly class OAuthClient
{
public function __construct(
private HttpClient $httpClient,
) {
}
/**
* Make GET request to OAuth provider
*
* @param array<string, string> $headers
* @return array<string, mixed>
*/
public function get(string $url, OAuthToken $token, array $headers = []): array
{
$response = $this->httpClient->get($url, [
'headers' => [
'Authorization' => $token->getAuthorizationHeader(),
...$headers,
],
]);
return json_decode($response->getBody(), true) ?? [];
}
/**
* Make POST request to OAuth provider
*
* @param array<string, mixed> $data
* @param array<string, string> $headers
* @return array<string, mixed>
*/
public function post(string $url, array $data = [], array $headers = []): array
{
$response = $this->httpClient->post($url, [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
...$headers,
],
'body' => http_build_query($data),
]);
return json_decode($response->getBody(), true) ?? [];
}
/**
* Make authenticated POST request with OAuth token
*
* @param array<string, mixed> $data
* @param array<string, string> $headers
* @return array<string, mixed>
*/
public function postAuthenticated(
string $url,
OAuthToken $token,
array $data = [],
array $headers = []
): array {
$response = $this->httpClient->post($url, [
'headers' => [
'Authorization' => $token->getAuthorizationHeader(),
'Content-Type' => 'application/json',
...$headers,
],
'body' => json_encode($data),
]);
return json_decode($response->getBody(), true) ?? [];
}
/**
* Make PUT request with OAuth token
*
* @param array<string, mixed> $data
* @param array<string, string> $headers
* @return array<string, mixed>
*/
public function put(
string $url,
OAuthToken $token,
array $data = [],
array $headers = []
): array {
$response = $this->httpClient->put($url, [
'headers' => [
'Authorization' => $token->getAuthorizationHeader(),
'Content-Type' => 'application/json',
...$headers,
],
'body' => json_encode($data),
]);
return json_decode($response->getBody(), true) ?? [];
}
/**
* Make DELETE request with OAuth token
*
* @param array<string, string> $headers
* @return array<string, mixed>
*/
public function delete(string $url, OAuthToken $token, array $headers = []): array
{
$response = $this->httpClient->delete($url, [
'headers' => [
'Authorization' => $token->getAuthorizationHeader(),
...$headers,
],
]);
return json_decode($response->getBody(), true) ?? [];
}
}