Implement RFC 9207 issuer validation in ClientOAuthProvider (#1605)

This commit is contained in:
Mike Kistler 2026-07-23 08:01:22 -07:00 • committed by GitHub
commit 4aade88558
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,6 +100,26 @@ public sealed class Program
/// </remarks>
public bool IncludeOfflineAccessInMetadata { get; set; }
/// <summary>
/// Gets or sets a value indicating whether authorization server metadata includes an issuer.
/// </summary>
public bool IncludeIssuerInMetadata { get; set; } = true;
/// <summary>
/// Gets or sets an issuer value that overrides the authorization server's metadata issuer.
/// </summary>
public string? MetadataIssuerOverride { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the authorization server advertises RFC 9207 support.
/// </summary>
public bool AuthorizationResponseIssParameterSupported { get; set; }
/// <summary>
/// Gets or sets the issuer included in authorization responses, or <see langword="null"/> to omit it.
/// </summary>
public string? AuthorizationResponseIssuer { get; set; }
/// <summary>
/// Gets or sets the code challenge methods advertised by metadata endpoints.
/// </summary>
@ -242,7 +262,7 @@ public sealed class Program
var metadata = new OAuthServerMetadata
{
Issuer = $"{_url}{issuerPath}",
Issuer = IncludeIssuerInMetadata ? MetadataIssuerOverride ?? $"{_url}{issuerPath}" : null,
AuthorizationEndpoint = $"{_url}/authorize",
TokenEndpoint = $"{_url}/token",
JwksUri = $"{_url}/.well-known/jwks.json",
@ -261,6 +281,7 @@ public sealed class Program
IntrospectionEndpoint = $"{_url}/introspect",
RegistrationEndpoint = $"{_url}/register",
ClientIdMetadataDocumentSupported = ClientIdMetadataDocumentSupported,
AuthorizationResponseIssParameterSupported = AuthorizationResponseIssParameterSupported ? true : null,
};
return Results.Ok(metadata);
@ -392,6 +413,10 @@ public sealed class Program
{
redirectUrl += $"&state={Uri.EscapeDataString(state)}";
}
if (!string.IsNullOrEmpty(AuthorizationResponseIssuer))
{
redirectUrl += $"&iss={Uri.EscapeDataString(AuthorizationResponseIssuer)}";
}
return Results.Redirect(redirectUrl);
});