| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Facile\JoseVerifier; |
| 6 | |
| 7 | use Facile\JoseVerifier\Exception\InvalidTokenExceptionInterface; |
| 8 | |
| 9 | /** |
| 10 | * @psalm-api |
| 11 | * |
| 12 | * @psalm-type JWKSetType = array{keys: list<array<string, mixed>>} |
| 13 | * @psalm-type JWTPayloadType = array<string, mixed> |
| 14 | * @psalm-type OpenIdDisplayType = non-empty-string |
| 15 | * @psalm-type OpenIdClaimType = 'normal'|'aggregated'|'distribuited' |
| 16 | * @psalm-type OpenIdResponseType = non-empty-string |
| 17 | * @psalm-type OpenIdResponseMode = 'query'|'fragment'|non-empty-string |
| 18 | * @psalm-type OpenIdGrantType = 'authorization_code'|'implicit'|'password'|'client_credentials'|'refresh_token'|'urn:ietf:params:oauth:grant-type:jwt-bearer'|'urn:ietf:params:oauth:grant-type:saml2-bearer'|'urn:ietf:params:oauth:grant-type:token-exchange'|non-empty-string |
| 19 | * @psalm-type OpenIdApplicationType = 'web'|'native' |
| 20 | * @psalm-type OpenIdSubjectType = 'pairwise'|'public' |
| 21 | * @psalm-type OpenIdAuthMethodType = 'client_secret_post'|'client_secret_basic'|'client_secret_jwt'|'private_key_jwt'|'none'|'tls_client_auth'|'self_signed_tls_client_auth' |
| 22 | * @psalm-type ClientMetadataType = array{ |
| 23 | * client_id: non-empty-string, |
| 24 | * client_secret?: string, |
| 25 | * redirect_uris?: list<non-empty-string>, |
| 26 | * jwks?: JWKSetType, |
| 27 | * jwks_uri?: non-empty-string, |
| 28 | * response_types?: list<OpenIdResponseType>, |
| 29 | * grant_types?: list<OpenIdGrantType>, |
| 30 | * application_type?: OpenIdApplicationType, |
| 31 | * contacts?: list<non-empty-string>, |
| 32 | * client_name?: string, |
| 33 | * logo_uri?: non-empty-string, |
| 34 | * client_uri?: non-empty-string, |
| 35 | * policy_uri?: non-empty-string, |
| 36 | * tos_uri?: non-empty-string, |
| 37 | * sector_identifier_uri?: non-empty-string, |
| 38 | * subject_type?: OpenIdSubjectType, |
| 39 | * authorization_signed_response_alg?: non-empty-string, |
| 40 | * authorization_encrypted_response_alg?: non-empty-string, |
| 41 | * authorization_encrypted_response_enc?: non-empty-string, |
| 42 | * id_token_signed_response_alg?: non-empty-string, |
| 43 | * id_token_encrypted_response_alg?: non-empty-string, |
| 44 | * id_token_encrypted_response_enc?: non-empty-string, |
| 45 | * userinfo_signed_response_alg?: non-empty-string, |
| 46 | * userinfo_encrypted_response_alg?: non-empty-string, |
| 47 | * userinfo_encrypted_response_enc?: non-empty-string, |
| 48 | * request_object_signing_alg?: non-empty-string, |
| 49 | * request_object_encryption_alg?: non-empty-string, |
| 50 | * request_object_encryption_enc?: non-empty-string, |
| 51 | * token_endpoint_auth_method?: OpenIdAuthMethodType, |
| 52 | * token_endpoint_auth_signing_alg?: non-empty-string, |
| 53 | * default_max_age?: int, |
| 54 | * require_auth_time?: bool, |
| 55 | * default_acr_values?: list<string>, |
| 56 | * initiate_login_uri?: non-empty-string, |
| 57 | * request_uris?: list<non-empty-string>, |
| 58 | * scope?: string, |
| 59 | * software_id?: non-empty-string, |
| 60 | * software_version?: non-empty-string, |
| 61 | * introspection_endpoint_auth_method?: non-empty-string, |
| 62 | * revocation_endpoint_auth_method?: non-empty-string, |
| 63 | * ... |
| 64 | * } |
| 65 | * @psalm-type IssuerMetadataType = array{issuer: string, jwks_uri: string, ...} |
| 66 | * @psalm-type IssuerRemoteMetadataType = array{ |
| 67 | * issuer: non-empty-string, |
| 68 | * authorization_endpoint: non-empty-string, |
| 69 | * token_endpoint?: non-empty-string, |
| 70 | * userinfo_endpoint?: non-empty-string, |
| 71 | * jwks_uri: non-empty-string, |
| 72 | * registration_endpoint?: non-empty-string, |
| 73 | * scopes_supported?: list<non-empty-string>, |
| 74 | * response_types_supported: non-empty-list<OpenIdResponseType>, |
| 75 | * response_modes_supported?: list<OpenIdResponseMode>, |
| 76 | * grant_types_supported?: list<OpenIdGrantType>, |
| 77 | * acr_values_supported?: list<non-empty-string>, |
| 78 | * subject_types_supported?: list<OpenIdSubjectType>, |
| 79 | * id_token_signing_alg_values_supported: non-empty-list<non-empty-string>, |
| 80 | * id_token_encryption_alg_values_supported?: list<non-empty-string>, |
| 81 | * id_token_encryption_enc_values_supported?: list<non-empty-string>, |
| 82 | * userinfo_signing_alg_values_supported?: list<non-empty-string>, |
| 83 | * userinfo_encryption_alg_values_supported?: list<non-empty-string>, |
| 84 | * userinfo_encryption_enc_values_supported?: list<non-empty-string>, |
| 85 | * request_object_signing_alg_values_supported?: list<non-empty-string>, |
| 86 | * request_object_encryption_alg_values_supported?: list<non-empty-string>, |
| 87 | * request_object_encryption_enc_values_supported?: list<non-empty-string>, |
| 88 | * token_endpoint_auth_methods_supported?: list<OpenIdAuthMethodType>, |
| 89 | * token_endpoint_auth_signing_alg_values_supported?: list<non-empty-string>, |
| 90 | * display_values_supported?: list<OpenIdDisplayType>, |
| 91 | * claim_types_supported?: list<OpenIdClaimType>, |
| 92 | * claims_supported?: list<non-empty-string>, |
| 93 | * service_documentation?: non-empty-string, |
| 94 | * claims_locales_supported?: list<non-empty-string>, |
| 95 | * ui_locales_supported?: list<non-empty-string>, |
| 96 | * claims_parameter_supported?: bool, |
| 97 | * request_parameter_supported?: bool, |
| 98 | * request_uri_parameter_supported?: bool, |
| 99 | * require_request_uri_registration?: bool, |
| 100 | * op_policy_uri?: non-empty-string, |
| 101 | * op_tos_uri?: non-empty-string, |
| 102 | * check_session_iframe?: non-empty-string, |
| 103 | * code_challenge_methods_supported?: list<non-empty-string>, |
| 104 | * authorization_signing_alg_values_supported?: list<non-empty-string>, |
| 105 | * authorization_encryption_alg_values_supported?: list<non-empty-string>, |
| 106 | * authorization_encryption_enc_values_supported?: list<non-empty-string>, |
| 107 | * introspection_endpoint?: non-empty-string, |
| 108 | * introspection_endpoint_auth_methods_supported?: list<non-empty-string>, |
| 109 | * introspection_endpoint_auth_signing_alg_values_supported?: list<non-empty-string>, |
| 110 | * introspection_signing_alg_values_supported?: list<non-empty-string>, |
| 111 | * introspection_encryption_alg_values_supported?: list<non-empty-string>, |
| 112 | * introspection_encryption_enc_values_supported?: list<non-empty-string>, |
| 113 | * revocation_endpoint?: non-empty-string, |
| 114 | * revocation_endpoint_auth_methods_supported?: list<non-empty-string>, |
| 115 | * revocation_endpoint_auth_signing_alg_values_supported?: list<non-empty-string>, |
| 116 | * end_session_iframe?: non-empty-string, |
| 117 | * frontchannel_logout_supported?: bool, |
| 118 | * frontchannel_logout_session_supported?: bool, |
| 119 | * backchannel_logout_supported?: bool, |
| 120 | * backchannel_logout_session_supported?: bool, |
| 121 | * mtls_endpoint_aliases?: array<string, string>, |
| 122 | * tls_client_certificate_bound_access_tokens?: bool, |
| 123 | * ... |
| 124 | * } |
| 125 | */ |
| 126 | interface TokenVerifierInterface |
| 127 | { |
| 128 | public function withNonce(?string $nonce): TokenVerifierInterface; |
| 129 | |
| 130 | public function withMaxAge(?int $maxAge): TokenVerifierInterface; |
| 131 | |
| 132 | /** |
| 133 | * Verify OpenID token. |
| 134 | * |
| 135 | * @throws InvalidTokenExceptionInterface |
| 136 | * |
| 137 | * @return array The JWT Payload |
| 138 | * |
| 139 | * @psalm-return JWTPayloadType |
| 140 | */ |
| 141 | public function verify(string $jwt): array; |
| 142 | } |