Implement RFC 9207 issuer validation in ClientOAuthProvider (#1605)
This commit is contained in:
parent
990bd76b53
commit
4aade88558
1 changed files with 707 additions and 149 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue