| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Auth; |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | final readonly class AuthorizationServerMetadata |
| 23: | { |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | public function __construct( |
| 36: | public string $issuer, |
| 37: | public ?string $authorizationEndpoint = null, |
| 38: | public ?string $tokenEndpoint = null, |
| 39: | public ?string $registrationEndpoint = null, |
| 40: | public ?ScopeSet $scopesSupported = null, |
| 41: | public ?array $codeChallengeMethodsSupported = null, |
| 42: | public ?bool $authorizationResponseIssParameterSupported = null, |
| 43: | public ?bool $clientIdMetadataDocumentSupported = null, |
| 44: | public ?array $tokenEndpointAuthMethodsSupported = null, |
| 45: | public ?array $tokenEndpointAuthSigningAlgValuesSupported = null, |
| 46: | public ?array $grantTypesSupported = null, |
| 47: | public ?array $authorizationGrantProfilesSupported = null, |
| 48: | ) { |
| 49: | } |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public static function fromArray(array $data): self |
| 55: | { |
| 56: | $reader = new MetadataReader('Authorization Server Metadata'); |
| 57: | $scopes = $reader->readStringList($data, 'scopes_supported'); |
| 58: | |
| 59: | return new self( |
| 60: | $reader->readRequiredString($data, 'issuer'), |
| 61: | $reader->readString($data, 'authorization_endpoint'), |
| 62: | $reader->readString($data, 'token_endpoint'), |
| 63: | $reader->readString($data, 'registration_endpoint'), |
| 64: | null === $scopes ? null : ScopeSet::fromList($scopes), |
| 65: | $reader->readStringList($data, 'code_challenge_methods_supported'), |
| 66: | $reader->readBool($data, 'authorization_response_iss_parameter_supported'), |
| 67: | $reader->readBool($data, 'client_id_metadata_document_supported'), |
| 68: | $reader->readStringList($data, 'token_endpoint_auth_methods_supported'), |
| 69: | $reader->readStringList($data, 'token_endpoint_auth_signing_alg_values_supported'), |
| 70: | $reader->readStringList($data, 'grant_types_supported'), |
| 71: | $reader->readStringList($data, 'authorization_grant_profiles_supported'), |
| 72: | ); |
| 73: | } |
| 74: | } |
| 75: | |