|
| 1 | +using System.Text.Json.Serialization; |
| 2 | + |
| 3 | +namespace ModelContextProtocol.TestOAuthServer; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// Represents the OAuth 2.0 Authorization Server Metadata as defined in RFC 8414. |
| 7 | +/// </summary> |
| 8 | +internal sealed class OAuthServerMetadata |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Gets or sets the issuer URL. |
| 12 | + /// REQUIRED. The authorization server's issuer identifier, which is a URL that uses the "https" scheme and has no query or fragment components. |
| 13 | + /// </summary> |
| 14 | + [JsonPropertyName("issuer")] |
| 15 | + public required string Issuer { get; init; } |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// Gets or sets the authorization endpoint URL. |
| 19 | + /// URL of the authorization server's authorization endpoint. This is REQUIRED unless no grant types are supported that use the authorization endpoint. |
| 20 | + /// </summary> |
| 21 | + [JsonPropertyName("authorization_endpoint")] |
| 22 | + public required string AuthorizationEndpoint { get; init; } |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Gets or sets the token endpoint URL. |
| 26 | + /// URL of the authorization server's token endpoint. This is REQUIRED unless only the implicit grant type is supported. |
| 27 | + /// </summary> |
| 28 | + [JsonPropertyName("token_endpoint")] |
| 29 | + public required string TokenEndpoint { get; init; } |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Gets or sets the JWKS URI. |
| 33 | + /// OPTIONAL. URL of the authorization server's JWK Set document. |
| 34 | + /// </summary> |
| 35 | + [JsonPropertyName("jwks_uri")] |
| 36 | + public required string JwksUri { get; init; } |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Gets or sets the registration endpoint URL for dynamic client registration. |
| 40 | + /// OPTIONAL. URL of the authorization server's OAuth 2.0 Dynamic Client Registration endpoint. |
| 41 | + /// </summary> |
| 42 | + [JsonPropertyName("registration_endpoint")] |
| 43 | + public string? RegistrationEndpoint { get; init; } |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Gets or sets the scopes supported by this server. |
| 47 | + /// RECOMMENDED. JSON array containing a list of the OAuth 2.0 scope values that this server supports. |
| 48 | + /// </summary> |
| 49 | + [JsonPropertyName("scopes_supported")] |
| 50 | + public required List<string> ScopesSupported { get; init; } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Gets or sets the response types supported by this server. |
| 54 | + /// RECOMMENDED. JSON array containing a list of the OAuth 2.0 "response_type" values that this server supports. |
| 55 | + /// </summary> |
| 56 | + [JsonPropertyName("response_types_supported")] |
| 57 | + public required List<string> ResponseTypesSupported { get; init; } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Gets or sets the response modes supported by this server. |
| 61 | + /// OPTIONAL. JSON array containing a list of the OAuth 2.0 "response_mode" values that this server supports. |
| 62 | + /// </summary> |
| 63 | + [JsonPropertyName("response_modes_supported")] |
| 64 | + public List<string>? ResponseModesSupported { get; init; } |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Gets or sets the grant types supported by this server. |
| 68 | + /// OPTIONAL. JSON array containing a list of the OAuth 2.0 grant type values that this server supports. |
| 69 | + /// </summary> |
| 70 | + [JsonPropertyName("grant_types_supported")] |
| 71 | + public required List<string> GrantTypesSupported { get; init; } |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Gets or sets the token endpoint authentication methods supported by this server. |
| 75 | + /// OPTIONAL. JSON array containing a list of client authentication methods supported by this token endpoint. |
| 76 | + /// </summary> |
| 77 | + [JsonPropertyName("token_endpoint_auth_methods_supported")] |
| 78 | + public required List<string> TokenEndpointAuthMethodsSupported { get; init; } |
| 79 | + |
| 80 | + /// <summary> |
| 81 | + /// Gets or sets the token endpoint authentication signing algorithms supported by this server. |
| 82 | + /// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the token endpoint. |
| 83 | + /// </summary> |
| 84 | + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] |
| 85 | + public List<string>? TokenEndpointAuthSigningAlgValuesSupported { get; init; } |
| 86 | + |
| 87 | + /// <summary> |
| 88 | + /// Gets or sets the introspection endpoint URL. |
| 89 | + /// OPTIONAL. URL of the authorization server's OAuth 2.0 introspection endpoint. |
| 90 | + /// </summary> |
| 91 | + [JsonPropertyName("introspection_endpoint")] |
| 92 | + public required string IntrospectionEndpoint { get; init; } |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// Gets or sets the introspection endpoint authentication methods supported by this server. |
| 96 | + /// OPTIONAL. JSON array containing a list of client authentication methods supported by this introspection endpoint. |
| 97 | + /// </summary> |
| 98 | + [JsonPropertyName("introspection_endpoint_auth_methods_supported")] |
| 99 | + public List<string>? IntrospectionEndpointAuthMethodsSupported { get; init; } |
| 100 | + |
| 101 | + /// <summary> |
| 102 | + /// Gets or sets the introspection endpoint authentication signing algorithms supported by this server. |
| 103 | + /// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the introspection endpoint. |
| 104 | + /// </summary> |
| 105 | + [JsonPropertyName("introspection_endpoint_auth_signing_alg_values_supported")] |
| 106 | + public List<string>? IntrospectionEndpointAuthSigningAlgValuesSupported { get; init; } |
| 107 | + |
| 108 | + /// <summary> |
| 109 | + /// Gets or sets the revocation endpoint URL. |
| 110 | + /// OPTIONAL. URL of the authorization server's OAuth 2.0 revocation endpoint. |
| 111 | + /// </summary> |
| 112 | + [JsonPropertyName("revocation_endpoint")] |
| 113 | + public string? RevocationEndpoint { get; init; } |
| 114 | + |
| 115 | + /// <summary> |
| 116 | + /// Gets or sets the revocation endpoint authentication methods supported by this server. |
| 117 | + /// OPTIONAL. JSON array containing a list of client authentication methods supported by this revocation endpoint. |
| 118 | + /// </summary> |
| 119 | + [JsonPropertyName("revocation_endpoint_auth_methods_supported")] |
| 120 | + public List<string>? RevocationEndpointAuthMethodsSupported { get; init; } |
| 121 | + |
| 122 | + /// <summary> |
| 123 | + /// Gets or sets the revocation endpoint authentication signing algorithms supported by this server. |
| 124 | + /// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the revocation endpoint. |
| 125 | + /// </summary> |
| 126 | + [JsonPropertyName("revocation_endpoint_auth_signing_alg_values_supported")] |
| 127 | + public List<string>? RevocationEndpointAuthSigningAlgValuesSupported { get; init; } |
| 128 | + |
| 129 | + /// <summary> |
| 130 | + /// Gets or sets the code challenge methods supported by this server. |
| 131 | + /// OPTIONAL. JSON array containing a list of Proof Key for Code Exchange (PKCE) code challenge methods supported by this server. |
| 132 | + /// </summary> |
| 133 | + [JsonPropertyName("code_challenge_methods_supported")] |
| 134 | + public required List<string> CodeChallengeMethodsSupported { get; init; } |
| 135 | + |
| 136 | + // OpenID Connect specific fields that are commonly included in OAuth metadata |
| 137 | + /// <summary> |
| 138 | + /// Gets or sets the subject types supported by this server. |
| 139 | + /// REQUIRED for OpenID Connect. JSON array containing a list of the Subject Identifier types that this OP supports. |
| 140 | + /// </summary> |
| 141 | + [JsonPropertyName("subject_types_supported")] |
| 142 | + public required List<string> SubjectTypesSupported { get; init; } |
| 143 | + |
| 144 | + /// <summary> |
| 145 | + /// Gets or sets the ID token signing algorithms supported by this server. |
| 146 | + /// REQUIRED for OpenID Connect. JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for the ID Token. |
| 147 | + /// </summary> |
| 148 | + [JsonPropertyName("id_token_signing_alg_values_supported")] |
| 149 | + public required List<string> IdTokenSigningAlgValuesSupported { get; init; } |
| 150 | + |
| 151 | + /// <summary> |
| 152 | + /// Gets or sets the claims supported by this server. |
| 153 | + /// RECOMMENDED for OpenID Connect. JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. |
| 154 | + /// </summary> |
| 155 | + [JsonPropertyName("claims_supported")] |
| 156 | + public required List<string> ClaimsSupported { get; init; } |
| 157 | +} |
0 commit comments