|
|
|
@ -127,8 +127,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Authentication demands can be triggered from the redirection endpoint
|
|
|
|
// to handle authorization callbacks but also from unknown endpoints
|
|
|
|
// when using the refresh token grant, to perform a token refresh dance.
|
|
|
|
@ -179,8 +184,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
(context.ExtractStateToken, |
|
|
|
context.RequireStateToken, |
|
|
|
context.ValidateStateToken) = context.EndpointType switch |
|
|
|
@ -215,8 +225,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
context.StateToken = context.EndpointType switch |
|
|
|
{ |
|
|
|
OpenIddictClientEndpointType.Redirection when context.ExtractStateToken |
|
|
|
@ -245,8 +260,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.RequireStateToken && string.IsNullOrEmpty(context.StateToken)) |
|
|
|
{ |
|
|
|
context.Reject( |
|
|
|
@ -268,8 +288,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateStateToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateStateToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -283,8 +303,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.StateTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.StateToken)) |
|
|
|
{ |
|
|
|
@ -341,8 +366,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Retrieve the client definition using the authorization server stored in the state token.
|
|
|
|
@ -391,8 +421,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.Issuer is { IsAbsoluteUri: true }, SR.GetResourceString(SR.ID4013)); |
|
|
|
|
|
|
|
var configuration = await context.Registration.ConfigurationManager.GetConfigurationAsync(default) ?? |
|
|
|
@ -477,8 +512,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
var (error, description, uri) = ( |
|
|
|
(string?) context.Request[Parameters.Error], |
|
|
|
(string?) context.Request[Parameters.ErrorDescription], |
|
|
|
@ -516,8 +556,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Resolve the negotiated grant type from the state token.
|
|
|
|
@ -564,8 +609,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Resolve the negotiated response type from the state token.
|
|
|
|
@ -591,8 +641,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
(context.ExtractAuthorizationCode, |
|
|
|
context.RequireAuthorizationCode, |
|
|
|
context.ValidateAuthorizationCode) = context.GrantType switch |
|
|
|
@ -668,8 +723,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
context.AuthorizationCode = context.EndpointType switch |
|
|
|
{ |
|
|
|
OpenIddictClientEndpointType.Redirection when context.ExtractAuthorizationCode |
|
|
|
@ -714,8 +774,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if ((context.RequireAuthorizationCode && string.IsNullOrEmpty(context.AuthorizationCode)) || |
|
|
|
(context.RequireFrontchannelAccessToken && string.IsNullOrEmpty(context.FrontchannelAccessToken)) || |
|
|
|
(context.RequireFrontchannelIdentityToken && string.IsNullOrEmpty(context.FrontchannelIdentityToken))) |
|
|
|
@ -739,8 +804,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateFrontchannelIdentityToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateFrontchannelIdentityToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -754,8 +819,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.FrontchannelIdentityTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.FrontchannelIdentityToken)) |
|
|
|
{ |
|
|
|
@ -812,8 +882,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.FrontchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
foreach (var group in context.FrontchannelIdentityTokenPrincipal.Claims |
|
|
|
@ -943,8 +1018,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.FrontchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Note: while an identity token typically contains a single audience represented
|
|
|
|
@ -983,8 +1063,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.FrontchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Note: the "azp" claim is optional, but if it's present, it MUST match the client identifier of the application.
|
|
|
|
@ -1022,8 +1107,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.FrontchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
@ -1080,8 +1170,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.FrontchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Resolve the signing algorithm used to sign the identity token. If the private
|
|
|
|
@ -1200,8 +1295,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateFrontchannelAccessToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateFrontchannelAccessToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -1215,8 +1310,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.FrontchannelAccessTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.FrontchannelAccessToken)) |
|
|
|
{ |
|
|
|
@ -1265,8 +1365,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateAuthorizationCode(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateAuthorizationCode(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -1280,8 +1380,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.AuthorizationCodePrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.AuthorizationCode)) |
|
|
|
{ |
|
|
|
@ -1337,8 +1442,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
(context.ExtractBackchannelAccessToken, |
|
|
|
context.RequireBackchannelAccessToken, |
|
|
|
context.ValidateBackchannelAccessToken) = context.GrantType switch |
|
|
|
@ -1424,8 +1534,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!context.ExtractBackchannelAccessToken && |
|
|
|
!context.ExtractBackchannelIdentityToken && |
|
|
|
!context.ExtractRefreshToken) |
|
|
|
@ -1465,8 +1580,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!context.ExtractBackchannelAccessToken && |
|
|
|
!context.ExtractBackchannelIdentityToken && |
|
|
|
!context.ExtractRefreshToken) |
|
|
|
@ -1530,7 +1650,7 @@ public static partial class OpenIddictClientHandlers |
|
|
|
private readonly OpenIddictClientService _service; |
|
|
|
|
|
|
|
public SendTokenRequest(OpenIddictClientService service) |
|
|
|
=> _service = service; |
|
|
|
=> _service = service ?? throw new ArgumentNullException(nameof(service)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -1543,8 +1663,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.TokenRequest is not null, SR.GetResourceString(SR.ID4008)); |
|
|
|
|
|
|
|
// Ensure the token endpoint is present and is a valid absolute URL.
|
|
|
|
@ -1575,8 +1700,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.TokenResponse is not null, SR.GetResourceString(SR.ID4007)); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(context.TokenResponse.Error)) |
|
|
|
@ -1609,8 +1739,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.TokenResponse is not null, SR.GetResourceString(SR.ID4007)); |
|
|
|
|
|
|
|
context.BackchannelAccessToken = context.ExtractBackchannelAccessToken switch |
|
|
|
@ -1651,8 +1786,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if ((context.RequireBackchannelAccessToken && string.IsNullOrEmpty(context.BackchannelAccessToken)) || |
|
|
|
(context.RequireBackchannelIdentityToken && string.IsNullOrEmpty(context.BackchannelIdentityToken)) || |
|
|
|
(context.RequireRefreshToken && string.IsNullOrEmpty(context.RefreshToken))) |
|
|
|
@ -1676,8 +1816,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateBackchannelIdentityToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateBackchannelIdentityToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -1691,8 +1831,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.BackchannelIdentityTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.BackchannelIdentityToken)) |
|
|
|
{ |
|
|
|
@ -1749,8 +1894,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.BackchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
foreach (var group in context.BackchannelIdentityTokenPrincipal.Claims |
|
|
|
@ -1880,8 +2030,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.BackchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Note: while an identity token typically contains a single audience represented
|
|
|
|
@ -1920,8 +2075,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.BackchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
// Note: the "azp" claim is optional, but if it's present, it MUST match the client identifier of the application.
|
|
|
|
@ -1959,8 +2119,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.BackchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
@ -2017,8 +2182,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.BackchannelIdentityTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.BackchannelAccessToken), SR.GetResourceString(SR.ID4010)); |
|
|
|
|
|
|
|
@ -2110,8 +2280,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateBackchannelAccessToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateBackchannelAccessToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -2125,8 +2295,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.BackchannelAccessTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.BackchannelAccessToken)) |
|
|
|
{ |
|
|
|
@ -2175,8 +2350,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateRefreshToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateRefreshToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -2190,8 +2365,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.RefreshTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.RefreshToken)) |
|
|
|
{ |
|
|
|
@ -2247,8 +2427,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
var configuration = await context.Registration.ConfigurationManager.GetConfigurationAsync(default) ?? |
|
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0140)); |
|
|
|
|
|
|
|
@ -2282,8 +2467,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
var configuration = await context.Registration.ConfigurationManager.GetConfigurationAsync(default) ?? |
|
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0140)); |
|
|
|
|
|
|
|
@ -2335,8 +2525,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Attach a new request instance if necessary.
|
|
|
|
context.UserinfoRequest ??= new OpenIddictRequest(); |
|
|
|
|
|
|
|
@ -2365,7 +2560,7 @@ public static partial class OpenIddictClientHandlers |
|
|
|
private readonly OpenIddictClientService _service; |
|
|
|
|
|
|
|
public SendUserinfoRequest(OpenIddictClientService service) |
|
|
|
=> _service = service; |
|
|
|
=> _service = service ?? throw new ArgumentNullException(nameof(service)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -2378,8 +2573,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.UserinfoRequest is not null, SR.GetResourceString(SR.ID4008)); |
|
|
|
|
|
|
|
// Ensure the userinfo endpoint is present and is a valid absolute URL.
|
|
|
|
@ -2414,8 +2614,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.UserinfoResponse is not null, SR.GetResourceString(SR.ID4007)); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(context.UserinfoResponse.Error)) |
|
|
|
@ -2448,8 +2653,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.RequireUserinfoToken && string.IsNullOrEmpty(context.UserinfoToken)) |
|
|
|
{ |
|
|
|
context.Reject( |
|
|
|
@ -2471,8 +2681,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public ValidateUserinfoToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public ValidateUserinfoToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -2486,8 +2696,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (context.UserinfoTokenPrincipal is not null || |
|
|
|
string.IsNullOrEmpty(context.UserinfoToken)) |
|
|
|
{ |
|
|
|
@ -2544,8 +2759,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.UserinfoTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
var configuration = await context.Registration.ConfigurationManager.GetConfigurationAsync(default) ?? |
|
|
|
@ -2612,8 +2832,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.UserinfoTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
var configuration = await context.Registration.ConfigurationManager.GetConfigurationAsync(default) ?? |
|
|
|
@ -2692,8 +2917,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// If an explicit grant type was specified, ensure it is supported by OpenIddict.
|
|
|
|
if (!string.IsNullOrEmpty(context.GrantType) && |
|
|
|
context.GrantType is not (GrantTypes.AuthorizationCode or GrantTypes.Implicit)) |
|
|
|
@ -2731,8 +2961,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Note: if the static registration cannot be found in the options, this may indicate
|
|
|
|
// the client was removed after the authorization dance started and thus, can no longer
|
|
|
|
// be used to authenticate users. In this case, throw an exception to abort the flow.
|
|
|
|
@ -2761,8 +2996,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// If an explicit grant type was specified, don't overwrite it.
|
|
|
|
if (!string.IsNullOrEmpty(context.GrantType)) |
|
|
|
{ |
|
|
|
@ -2846,8 +3086,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// In OpenIddict, per-authorization demand values are stored in an encrypted and signed token
|
|
|
|
// called "state token", that allows flowing per-authorization demand data like the issuer
|
|
|
|
// targeted by the authorization demand or secret values like the code verifier used to
|
|
|
|
@ -2885,8 +3130,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// If an explicit response type was specified, don't overwrite it.
|
|
|
|
if (!string.IsNullOrEmpty(context.ResponseType)) |
|
|
|
{ |
|
|
|
@ -3078,8 +3328,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// If an explicit response type was specified, don't overwrite it.
|
|
|
|
if (!string.IsNullOrEmpty(context.ResponseMode)) |
|
|
|
{ |
|
|
|
@ -3185,8 +3440,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
context.ClientId ??= context.Registration.ClientId; |
|
|
|
|
|
|
|
return default; |
|
|
|
@ -3209,8 +3469,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Unlike OpenID Connect, OAuth 2.0 and 2.1 don't require specifying a redirect_uri.
|
|
|
|
// To keep OpenIddict compatible with OAuth 2.0/2.1 deployments, the redirect_uri
|
|
|
|
// is not required for OAuth 2.0 requests but an exception will be thrown later
|
|
|
|
@ -3237,8 +3502,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// If an explicit set of scopes was specified, don't overwrite it.
|
|
|
|
if (context.Scopes.Count > 0) |
|
|
|
{ |
|
|
|
@ -3284,8 +3554,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Generate a new crypto-secure random identifier that will
|
|
|
|
// be used as the non-guessable part of the state token.
|
|
|
|
var data = new byte[256 / 8]; |
|
|
|
@ -3317,8 +3592,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
var configuration = await context.Registration.ConfigurationManager.GetConfigurationAsync(default) ?? |
|
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0140)); |
|
|
|
|
|
|
|
@ -3362,8 +3642,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Don't attach a code challenge method if no authorization code is requested as some implementations
|
|
|
|
// (like OpenIddict server) are known to eagerly block authorization requests that specify an invalid
|
|
|
|
// code_challenge/code_challenge_method/response_type combination (e.g response_type=id_token).
|
|
|
|
@ -3464,8 +3749,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
Debug.Assert(context.Issuer is { IsAbsoluteUri: true }, SR.GetResourceString(SR.ID4013)); |
|
|
|
Debug.Assert(context.Principal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006)); |
|
|
|
|
|
|
|
@ -3556,8 +3846,8 @@ public static partial class OpenIddictClientHandlers |
|
|
|
{ |
|
|
|
private readonly IOpenIddictClientDispatcher _dispatcher; |
|
|
|
|
|
|
|
public GenerateStateToken(IOpenIddictClientDispatcher dispatcher!!) |
|
|
|
=> _dispatcher = dispatcher; |
|
|
|
public GenerateStateToken(IOpenIddictClientDispatcher dispatcher) |
|
|
|
=> _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
@ -3571,8 +3861,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public async ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
var notification = new GenerateTokenContext(context.Transaction) |
|
|
|
{ |
|
|
|
Principal = context.StateTokenPrincipal!, |
|
|
|
@ -3623,8 +3918,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// While OAuth 2.0/2.1 allows sending an authorization request without a redirect_uri,
|
|
|
|
// doing so is illegal in OpenID Connect and such requests will always be rejected.
|
|
|
|
// To make that requirement explicit, an exception is proactively thrown here.
|
|
|
|
@ -3653,8 +3953,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessChallengeContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
// Note: while the exact order of the parameters has typically no effect on how requests
|
|
|
|
// are handled by an authorization server, client_id and redirect_uri are deliberately
|
|
|
|
// set first so that they appear early in the URL (when GET requests are used), making
|
|
|
|
@ -3709,8 +4014,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(TContext context!!) |
|
|
|
public ValueTask HandleAsync(TContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(context.Transaction.Response?.Error)) |
|
|
|
{ |
|
|
|
context.Reject( |
|
|
|
@ -3741,8 +4051,13 @@ public static partial class OpenIddictClientHandlers |
|
|
|
.Build(); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public ValueTask HandleAsync(ProcessErrorContext context!!) |
|
|
|
public ValueTask HandleAsync(ProcessErrorContext context) |
|
|
|
{ |
|
|
|
if (context is null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(context)); |
|
|
|
} |
|
|
|
|
|
|
|
context.Response.Error = context.Error; |
|
|
|
context.Response.ErrorDescription = context.ErrorDescription; |
|
|
|
context.Response.ErrorUri = context.ErrorUri; |
|
|
|
|