using System.Text.Json.Serialization;
namespace ModelContextProtocol.TestOAuthServer;
///
/// Represents the OAuth 2.0 Authorization Server Metadata as defined in RFC 8414.
///
internal sealed class OAuthServerMetadata
{
///
/// Gets or sets the issuer URL.
/// REQUIRED. The authorization server's issuer identifier, which is a URL that uses the "https" scheme and has no query or fragment components.
///
[JsonPropertyName("issuer")]
public required string Issuer { get; init; }
///
/// Gets or sets the authorization endpoint URL.
/// URL of the authorization server's authorization endpoint. This is REQUIRED unless no grant types are supported that use the authorization endpoint.
///
[JsonPropertyName("authorization_endpoint")]
public required string AuthorizationEndpoint { get; init; }
///
/// Gets or sets the token endpoint URL.
/// URL of the authorization server's token endpoint. This is REQUIRED unless only the implicit grant type is supported.
///
[JsonPropertyName("token_endpoint")]
public required string TokenEndpoint { get; init; }
///
/// Gets or sets the JWKS URI.
/// OPTIONAL. URL of the authorization server's JWK Set document.
///
[JsonPropertyName("jwks_uri")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? JwksUri { get; init; }
///
/// Gets or sets the registration endpoint URL for dynamic client registration.
/// OPTIONAL. URL of the authorization server's OAuth 2.0 Dynamic Client Registration endpoint.
///
[JsonPropertyName("registration_endpoint")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? RegistrationEndpoint { get; init; }
///
/// Gets or sets the scopes supported by this server.
/// RECOMMENDED. JSON array containing a list of the OAuth 2.0 scope values that this server supports.
///
[JsonPropertyName("scopes_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? ScopesSupported { get; init; }
///
/// Gets or sets the response types supported by this server.
/// RECOMMENDED. JSON array containing a list of the OAuth 2.0 "response_type" values that this server supports.
///
[JsonPropertyName("response_types_supported")]
public required List ResponseTypesSupported { get; init; }
///
/// Gets or sets the response modes supported by this server.
/// OPTIONAL. JSON array containing a list of the OAuth 2.0 "response_mode" values that this server supports.
///
[JsonPropertyName("response_modes_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? ResponseModesSupported { get; init; }
///
/// Gets or sets the grant types supported by this server.
/// OPTIONAL. JSON array containing a list of the OAuth 2.0 grant type values that this server supports.
///
[JsonPropertyName("grant_types_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? GrantTypesSupported { get; init; }
///
/// Gets or sets the token endpoint authentication methods supported by this server.
/// OPTIONAL. JSON array containing a list of client authentication methods supported by this token endpoint.
///
[JsonPropertyName("token_endpoint_auth_methods_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? TokenEndpointAuthMethodsSupported { get; init; }
///
/// Gets or sets the token endpoint authentication signing algorithms supported by this server.
/// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the token endpoint.
///
[JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? TokenEndpointAuthSigningAlgValuesSupported { get; init; }
///
/// Gets or sets the introspection endpoint URL.
/// OPTIONAL. URL of the authorization server's OAuth 2.0 introspection endpoint.
///
[JsonPropertyName("introspection_endpoint")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? IntrospectionEndpoint { get; init; }
///
/// Gets or sets the introspection endpoint authentication methods supported by this server.
/// OPTIONAL. JSON array containing a list of client authentication methods supported by this introspection endpoint.
///
[JsonPropertyName("introspection_endpoint_auth_methods_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? IntrospectionEndpointAuthMethodsSupported { get; init; }
///
/// Gets or sets the introspection endpoint authentication signing algorithms supported by this server.
/// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the introspection endpoint.
///
[JsonPropertyName("introspection_endpoint_auth_signing_alg_values_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? IntrospectionEndpointAuthSigningAlgValuesSupported { get; init; }
///
/// Gets or sets the revocation endpoint URL.
/// OPTIONAL. URL of the authorization server's OAuth 2.0 revocation endpoint.
///
[JsonPropertyName("revocation_endpoint")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? RevocationEndpoint { get; init; }
///
/// Gets or sets the revocation endpoint authentication methods supported by this server.
/// OPTIONAL. JSON array containing a list of client authentication methods supported by this revocation endpoint.
///
[JsonPropertyName("revocation_endpoint_auth_methods_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? RevocationEndpointAuthMethodsSupported { get; init; }
///
/// Gets or sets the revocation endpoint authentication signing algorithms supported by this server.
/// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the revocation endpoint.
///
[JsonPropertyName("revocation_endpoint_auth_signing_alg_values_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? RevocationEndpointAuthSigningAlgValuesSupported { get; init; }
///
/// Gets or sets the code challenge methods supported by this server.
/// OPTIONAL. JSON array containing a list of Proof Key for Code Exchange (PKCE) code challenge methods supported by this server.
///
[JsonPropertyName("code_challenge_methods_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? CodeChallengeMethodsSupported { get; init; }
// OpenID Connect specific fields that are commonly included in OAuth metadata
///
/// Gets or sets the subject types supported by this server.
/// REQUIRED for OpenID Connect. JSON array containing a list of the Subject Identifier types that this OP supports.
///
[JsonPropertyName("subject_types_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? SubjectTypesSupported { get; init; }
///
/// Gets or sets the ID token signing algorithms supported by this server.
/// REQUIRED for OpenID Connect. JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for the ID Token.
///
[JsonPropertyName("id_token_signing_alg_values_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? IdTokenSigningAlgValuesSupported { get; init; }
///
/// Gets or sets the claims supported by this server.
/// 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.
///
[JsonPropertyName("claims_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List? ClaimsSupported { get; init; }
///
/// Gets or sets a value indicating whether CIMD client IDs are supported.
///
[JsonPropertyName("client_id_metadata_document_supported")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? ClientIdMetadataDocumentSupported { get; init; }
}