|
|
@ -40,25 +40,20 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
WaitMarshalledAuthentication.Descriptor, |
|
|
WaitMarshalledAuthentication.Descriptor, |
|
|
|
|
|
|
|
|
RestoreClientRegistrationFromMarshalledContext.Descriptor, |
|
|
RestoreClientRegistrationFromMarshalledContext.Descriptor, |
|
|
RestoreStateTokenFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreStateTokenPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
EvaluateValidatedUpfrontTokensForMarshalledContext.Descriptor, |
|
|
RestoreHostAuthenticationPropertiesFromMarshalledAuthentication.Descriptor, |
|
|
ResolveValidatedStateTokenFromMarshalledContext.Descriptor, |
|
|
|
|
|
EvaluateValidatedFrontchannelTokensForMarshalledContext.Descriptor, |
|
|
|
|
|
ResolveValidatedFrontchannelTokensFromMarshalledContext.Descriptor, |
|
|
|
|
|
EvaluateValidatedBackchannelTokensForMarshalledContext.Descriptor, |
|
|
|
|
|
|
|
|
|
|
|
DisableStateTokenRedeeming.Descriptor, |
|
|
|
|
|
DisableTokenRequestSending.Descriptor, |
|
|
|
|
|
DisableUserInfoRequestSending.Descriptor, |
|
|
|
|
|
|
|
|
RedirectProtocolActivation.Descriptor, |
|
|
RedirectProtocolActivation.Descriptor, |
|
|
ResolveRequestForgeryProtection.Descriptor, |
|
|
ResolveRequestForgeryProtection.Descriptor, |
|
|
|
|
|
|
|
|
RestoreFrontchannelTokensFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreFrontchannelIdentityTokenPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreFrontchannelAccessTokenPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreAuthorizationCodePrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreTokenResponseFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreBackchannelTokensFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreBackchannelIdentityTokenPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreBackchannelAccessTokenPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreRefreshTokenPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreUserInfoDetailsFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
RestoreMergedPrincipalFromMarshalledAuthentication.Descriptor, |
|
|
|
|
|
|
|
|
|
|
|
CompleteAuthenticationOperation.Descriptor, |
|
|
CompleteAuthenticationOperation.Descriptor, |
|
|
UntrackMarshalledAuthenticationOperation.Descriptor, |
|
|
UntrackMarshalledAuthenticationOperation.Descriptor, |
|
|
|
|
|
|
|
|
@ -613,7 +608,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0379)); |
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0379)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// At this point, user authentication demands cannot complete until the authorization response has been
|
|
|
// At this point, the user authentication demand cannot complete until the authorization response has been
|
|
|
// returned to the redirection endpoint (materialized as a registered protocol activation URI) and handled
|
|
|
// returned to the redirection endpoint (materialized as a registered protocol activation URI) and handled
|
|
|
// by OpenIddict via the ProcessRequest event. Since it is asynchronous by nature, this process requires
|
|
|
// by OpenIddict via the ProcessRequest event. Since it is asynchronous by nature, this process requires
|
|
|
// using a signal mechanism to unblock the authentication operation once it is complete. For that, the
|
|
|
// using a signal mechanism to unblock the authentication operation once it is complete. For that, the
|
|
|
@ -697,8 +692,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
|
|
|
|
|
|
(context.Configuration, context.Registration) = context.EndpointType switch |
|
|
(context.Configuration, context.Registration) = context.EndpointType switch |
|
|
{ |
|
|
{ |
|
|
// When the authentication context is marshalled, restore the
|
|
|
// When the authentication demand is marshalled from a different context,
|
|
|
// issuer registration and configuration from the other instance.
|
|
|
// restore the registration and configuration from the other instance.
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
=> (notification.Configuration, notification.Registration), |
|
|
=> (notification.Configuration, notification.Registration), |
|
|
|
|
|
|
|
|
@ -710,14 +705,14 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the state token
|
|
|
/// Contains the logic responsible for determining the types of
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// tokens to validate upfront when the context is marshalled.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public sealed class RestoreStateTokenFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class EvaluateValidatedUpfrontTokensForMarshalledContext : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
public RestoreStateTokenFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public EvaluateValidatedUpfrontTokensForMarshalledContext(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -726,8 +721,49 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
.UseSingletonHandler<RestoreStateTokenFromMarshalledAuthentication>() |
|
|
.UseSingletonHandler<EvaluateValidatedUpfrontTokensForMarshalledContext>() |
|
|
.SetOrder(ResolveValidatedStateToken.Descriptor.Order + 500) |
|
|
.SetOrder(EvaluateValidatedUpfrontTokens.Descriptor.Order + 250) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
// When the authentication demand is marshalled from a different context, always
|
|
|
|
|
|
// extract and validate the state token to ensure the authentication details
|
|
|
|
|
|
// contained in the state token principal can be used to validate the operation.
|
|
|
|
|
|
if (context.EndpointType is OpenIddictClientEndpointType.Unknown && _marshal.IsTracked(context.Nonce)) |
|
|
|
|
|
{ |
|
|
|
|
|
context.ExtractStateToken = context.RequireStateToken = true; |
|
|
|
|
|
context.ValidateStateToken = context.RejectStateToken = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for resolving the state token to validate upfront from the marshalled context.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class ResolveValidatedStateTokenFromMarshalledContext : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public ResolveValidatedStateTokenFromMarshalledContext(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<ResolveValidatedStateTokenFromMarshalledContext>() |
|
|
|
|
|
.SetOrder(ResolveValidatedStateToken.Descriptor.Order + 250) |
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
@ -740,12 +776,12 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
|
|
|
|
|
|
context.StateToken = context.EndpointType switch |
|
|
context.StateToken = context.EndpointType switch |
|
|
{ |
|
|
{ |
|
|
// When the authentication context is marshalled, restore the state token from the other instance.
|
|
|
// When the authentication demand is marshalled from a different context,
|
|
|
|
|
|
// always restore the state token from the instance that extracted it.
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
=> notification.StateToken, |
|
|
=> notification.StateToken, |
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
_ => null |
|
|
_ => context.StateToken |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
return ValueTask.CompletedTask; |
|
|
@ -753,14 +789,14 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the state token
|
|
|
/// Contains the logic responsible for determining the set of
|
|
|
/// principal from the marshalled authentication context, if applicable.
|
|
|
/// frontchannel tokens to validate when the context is marshalled.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public sealed class RestoreStateTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class EvaluateValidatedFrontchannelTokensForMarshalledContext : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
public RestoreStateTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public EvaluateValidatedFrontchannelTokensForMarshalledContext(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -769,8 +805,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
.UseSingletonHandler<RestoreStateTokenPrincipalFromMarshalledAuthentication>() |
|
|
.UseSingletonHandler<EvaluateValidatedFrontchannelTokensForMarshalledContext>() |
|
|
.SetOrder(ValidateStateToken.Descriptor.Order + 500) |
|
|
.SetOrder(EvaluateValidatedFrontchannelTokens.Descriptor.Order + 250) |
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
@ -781,30 +817,30 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
context.StateTokenPrincipal = context.EndpointType switch |
|
|
// When the authentication demand is expected to be marshalled to a different context,
|
|
|
|
|
|
// always skip the validation of all the frontchannel tokens by default as the security
|
|
|
|
|
|
// principals they contain are not needed to marshal the authentication demand.
|
|
|
|
|
|
if (context.EndpointType is |
|
|
|
|
|
OpenIddictClientEndpointType.Redirection or |
|
|
|
|
|
OpenIddictClientEndpointType.PostLogoutRedirection && _marshal.IsTracked(context.Nonce)) |
|
|
{ |
|
|
{ |
|
|
// When the authentication context is marshalled, restore
|
|
|
context.ValidateAuthorizationCode = context.RejectAuthorizationCode = false; |
|
|
// the state token principal from the other instance.
|
|
|
context.ValidateFrontchannelAccessToken = context.RejectFrontchannelAccessToken = false; |
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
context.ValidateFrontchannelIdentityToken = context.RejectFrontchannelIdentityToken = false; |
|
|
=> notification.StateTokenPrincipal, |
|
|
} |
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.StateTokenPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
return ValueTask.CompletedTask; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the host authentication
|
|
|
/// Contains the logic responsible for resolving the frontchannel tokens from the marshalled context.
|
|
|
/// properties from the marshalled authentication context, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public sealed class RestoreHostAuthenticationPropertiesFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class ResolveValidatedFrontchannelTokensFromMarshalledContext : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
public RestoreHostAuthenticationPropertiesFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public ResolveValidatedFrontchannelTokensFromMarshalledContext(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -813,8 +849,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
.UseSingletonHandler<RestoreHostAuthenticationPropertiesFromMarshalledAuthentication>() |
|
|
.UseSingletonHandler<ResolveValidatedFrontchannelTokensFromMarshalledContext>() |
|
|
.SetOrder(ResolveHostAuthenticationPropertiesFromStateToken.Descriptor.Order + 500) |
|
|
.SetOrder(ResolveValidatedFrontchannelTokens.Descriptor.Order + 250) |
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
@ -825,21 +861,271 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
// When the authentication context is marshalled, restore the
|
|
|
// When the authentication context is marshalled, restore the frontchannel tokens from the other instance.
|
|
|
// host authentication properties from the other instance.
|
|
|
|
|
|
if (context.EndpointType is OpenIddictClientEndpointType.Unknown && |
|
|
if (context.EndpointType is OpenIddictClientEndpointType.Unknown && |
|
|
_marshal.TryGetResult(context.Nonce, out var notification)) |
|
|
_marshal.TryGetResult(context.Nonce, out var notification)) |
|
|
{ |
|
|
{ |
|
|
foreach (var property in notification.Properties) |
|
|
context.AuthorizationCode = notification.AuthorizationCode; |
|
|
|
|
|
context.FrontchannelAccessToken = notification.FrontchannelAccessToken; |
|
|
|
|
|
context.FrontchannelAccessTokenExpirationDate = notification.FrontchannelAccessTokenExpirationDate; |
|
|
|
|
|
context.FrontchannelIdentityToken = notification.FrontchannelIdentityToken; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for determining the set of
|
|
|
|
|
|
/// backchannel tokens to validate when the context is marshalled.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class EvaluateValidatedBackchannelTokensForMarshalledContext : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public EvaluateValidatedBackchannelTokensForMarshalledContext(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<EvaluateValidatedBackchannelTokensForMarshalledContext>() |
|
|
|
|
|
.SetOrder(EvaluateValidatedBackchannelTokens.Descriptor.Order + 250) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
// When the authentication demand is expected to be marshalled to a different context,
|
|
|
|
|
|
// always skip the validation of all the backchannel tokens by default as the security
|
|
|
|
|
|
// principals they contain are not needed to marshal the authentication demand.
|
|
|
|
|
|
if (context.EndpointType is |
|
|
|
|
|
OpenIddictClientEndpointType.Redirection or |
|
|
|
|
|
OpenIddictClientEndpointType.PostLogoutRedirection && _marshal.IsTracked(context.Nonce)) |
|
|
|
|
|
{ |
|
|
|
|
|
context.ValidateBackchannelAccessToken = context.RejectBackchannelAccessToken = false; |
|
|
|
|
|
context.ValidateBackchannelIdentityToken = context.RejectBackchannelIdentityToken = false; |
|
|
|
|
|
context.ValidateIssuedToken = context.RejectIssuedToken = false; |
|
|
|
|
|
context.ValidateRefreshToken = context.RejectRefreshToken = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for disabling the redeeming of the state token, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class DisableStateTokenRedeeming : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public DisableStateTokenRedeeming(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<DisableStateTokenRedeeming>() |
|
|
|
|
|
.SetOrder(RedeemStateTokenEntry.Descriptor.Order - 250) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.DisableStateTokenRedeeming = context.EndpointType switch |
|
|
{ |
|
|
{ |
|
|
context.Properties[property.Key] = property.Value; |
|
|
// When the authentication demand is expected to be marshalled to a different context,
|
|
|
|
|
|
// disable the redeeming of the state token to ensure it is not in an invalid state
|
|
|
|
|
|
// when the marshalled authentication demand is processed by the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Redirection or |
|
|
|
|
|
OpenIddictClientEndpointType.PostLogoutRedirection when _marshal.IsTracked(context.Nonce) |
|
|
|
|
|
=> true, |
|
|
|
|
|
|
|
|
|
|
|
_ => context.DisableStateTokenRedeeming |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for preventing a token request from being sent, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class DisableTokenRequestSending : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public DisableTokenRequestSending(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<DisableTokenRequestSending>() |
|
|
|
|
|
.SetOrder(EvaluateTokenRequest.Descriptor.Order + 250) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.SendTokenRequest = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication demand is expected to be marshalled to a different
|
|
|
|
|
|
// context, do not send a token request and let the other instance do it.
|
|
|
|
|
|
OpenIddictClientEndpointType.Redirection or |
|
|
|
|
|
OpenIddictClientEndpointType.PostLogoutRedirection when _marshal.IsTracked(context.Nonce) |
|
|
|
|
|
=> false, |
|
|
|
|
|
|
|
|
|
|
|
_ => context.SendTokenRequest |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for preventing a userinfo request from being sent, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class DisableUserInfoRequestSending : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public DisableUserInfoRequestSending(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<DisableUserInfoRequestSending>() |
|
|
|
|
|
.SetOrder(EvaluateUserInfoRequest.Descriptor.Order + 250) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
|
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.SendUserInfoRequest = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication demand is expected to be marshalled to a different
|
|
|
|
|
|
// context, do not send a userinfo request and let the other instance do it.
|
|
|
|
|
|
OpenIddictClientEndpointType.Redirection or |
|
|
|
|
|
OpenIddictClientEndpointType.PostLogoutRedirection when _marshal.IsTracked(context.Nonce) |
|
|
|
|
|
=> false, |
|
|
|
|
|
|
|
|
|
|
|
_ => context.SendUserInfoRequest |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
return ValueTask.CompletedTask; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for restoring the state token
|
|
|
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
|
|
|
public sealed class RestoreStateTokenFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
public RestoreStateTokenFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<RestoreStateTokenFromMarshalledAuthentication>() |
|
|
|
|
|
.SetOrder(ResolveValidatedStateToken.Descriptor.Order + 500) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for restoring the state token
|
|
|
|
|
|
/// principal from the marshalled authentication context, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
|
|
|
public sealed class RestoreStateTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
public RestoreStateTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<RestoreStateTokenPrincipalFromMarshalledAuthentication>() |
|
|
|
|
|
.SetOrder(ValidateStateToken.Descriptor.Order + 500) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Contains the logic responsible for restoring the host authentication
|
|
|
|
|
|
/// properties from the marshalled authentication context, if applicable.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
|
|
|
public sealed class RestoreHostAuthenticationPropertiesFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
|
|
|
{ |
|
|
|
|
|
public RestoreHostAuthenticationPropertiesFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
|
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static OpenIddictClientHandlerDescriptor Descriptor { get; } |
|
|
|
|
|
= OpenIddictClientHandlerDescriptor.CreateBuilder<ProcessAuthenticationContext>() |
|
|
|
|
|
.AddFilter<RequireAuthenticationNonce>() |
|
|
|
|
|
.UseSingletonHandler<RestoreHostAuthenticationPropertiesFromMarshalledAuthentication>() |
|
|
|
|
|
.SetOrder(ResolveHostAuthenticationPropertiesFromStateToken.Descriptor.Order + 500) |
|
|
|
|
|
.SetType(OpenIddictClientHandlerType.BuiltIn) |
|
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for redirecting the protocol activation to
|
|
|
/// Contains the logic responsible for redirecting the protocol activation to
|
|
|
/// the instance that initially started the authentication demand, if applicable.
|
|
|
/// the instance that initially started the authentication demand, if applicable.
|
|
|
@ -984,12 +1270,11 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
/// Contains the logic responsible for restoring the frontchannel tokens
|
|
|
/// Contains the logic responsible for restoring the frontchannel tokens
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreFrontchannelTokensFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreFrontchannelTokensFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreFrontchannelTokensFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreFrontchannelTokensFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1003,38 +1288,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
(context.AuthorizationCode, |
|
|
|
|
|
context.FrontchannelAccessToken, |
|
|
|
|
|
context.FrontchannelIdentityToken) = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the tokens from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> (notification.AuthorizationCode, notification.FrontchannelAccessToken, notification.FrontchannelIdentityToken), |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => (context.AuthorizationCode, context.FrontchannelAccessToken, context.FrontchannelIdentityToken) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the frontchannel identity
|
|
|
/// Contains the logic responsible for restoring the frontchannel identity
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreFrontchannelIdentityTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreFrontchannelIdentityTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreFrontchannelIdentityTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreFrontchannelIdentityTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1048,37 +1313,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.FrontchannelIdentityTokenPrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the
|
|
|
|
|
|
// frontchannel identity token principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.FrontchannelIdentityTokenPrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.FrontchannelIdentityTokenPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the frontchannel access
|
|
|
/// Contains the logic responsible for restoring the frontchannel access
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreFrontchannelAccessTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreFrontchannelAccessTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreFrontchannelAccessTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreFrontchannelAccessTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1092,37 +1338,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.FrontchannelAccessTokenPrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the
|
|
|
|
|
|
// frontchannel access token principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.FrontchannelAccessTokenPrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.FrontchannelAccessTokenPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the authorization code
|
|
|
/// Contains the logic responsible for restoring the authorization code
|
|
|
/// principal from the marshalled authentication context, if applicable.
|
|
|
/// principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreAuthorizationCodePrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreAuthorizationCodePrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreAuthorizationCodePrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreAuthorizationCodePrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1136,37 +1363,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.AuthorizationCodePrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the
|
|
|
|
|
|
// authorization code principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.AuthorizationCodePrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.AuthorizationCodePrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the token response
|
|
|
/// Contains the logic responsible for restoring the token response
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreTokenResponseFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreTokenResponseFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreTokenResponseFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreTokenResponseFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1180,36 +1388,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.TokenResponse = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the token response from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.TokenResponse, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.TokenResponse |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the backchannel tokens
|
|
|
/// Contains the logic responsible for restoring the backchannel tokens
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreBackchannelTokensFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreBackchannelTokensFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreBackchannelTokensFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreBackchannelTokensFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1223,38 +1413,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
(context.BackchannelAccessToken, |
|
|
|
|
|
context.BackchannelIdentityToken, |
|
|
|
|
|
context.RefreshToken) = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the tokens from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> (notification.BackchannelAccessToken, notification.BackchannelIdentityToken, notification.RefreshToken), |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => (context.BackchannelAccessToken, context.BackchannelIdentityToken, context.RefreshToken) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the backchannel identity
|
|
|
/// Contains the logic responsible for restoring the backchannel identity
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreBackchannelIdentityTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreBackchannelIdentityTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreBackchannelIdentityTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreBackchannelIdentityTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1268,37 +1438,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.BackchannelIdentityTokenPrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the
|
|
|
|
|
|
// frontchannel identity token principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.BackchannelIdentityTokenPrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.BackchannelIdentityTokenPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the frontchannel access
|
|
|
/// Contains the logic responsible for restoring the frontchannel access
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// token principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreBackchannelAccessTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreBackchannelAccessTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreBackchannelAccessTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreBackchannelAccessTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1312,37 +1463,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.BackchannelAccessTokenPrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the
|
|
|
|
|
|
// frontchannel access token principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.BackchannelAccessTokenPrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.BackchannelAccessTokenPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the refresh token
|
|
|
/// Contains the logic responsible for restoring the refresh token
|
|
|
/// principal from the marshalled authentication context, if applicable.
|
|
|
/// principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreRefreshTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreRefreshTokenPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreRefreshTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreRefreshTokenPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1356,37 +1488,18 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.RefreshTokenPrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore
|
|
|
|
|
|
// the refresh token principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.RefreshTokenPrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.RefreshTokenPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the userinfo details
|
|
|
/// Contains the logic responsible for restoring the userinfo details
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreUserInfoDetailsFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreUserInfoDetailsFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreUserInfoDetailsFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreUserInfoDetailsFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1400,35 +1513,17 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
(context.UserInfoResponse, context.UserInfoTokenPrincipal, context.UserInfoToken) = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the userinfo details from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> (notification.UserInfoResponse, notification.UserInfoTokenPrincipal, notification.UserInfoToken), |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => (context.UserInfoResponse, context.UserInfoTokenPrincipal, context.UserInfoToken) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Contains the logic responsible for restoring the merged principal from the marshalled authentication context, if applicable.
|
|
|
/// Contains the logic responsible for restoring the merged principal from the marshalled authentication context, if applicable.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Obsolete("This class is obsolete and will be removed in a future version.")] |
|
|
public sealed class RestoreMergedPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
public sealed class RestoreMergedPrincipalFromMarshalledAuthentication : IOpenIddictClientHandler<ProcessAuthenticationContext> |
|
|
{ |
|
|
{ |
|
|
private readonly OpenIddictClientSystemIntegrationMarshal _marshal; |
|
|
|
|
|
|
|
|
|
|
|
public RestoreMergedPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
public RestoreMergedPrincipalFromMarshalledAuthentication(OpenIddictClientSystemIntegrationMarshal marshal) |
|
|
=> _marshal = marshal ?? throw new ArgumentNullException(nameof(marshal)); |
|
|
=> throw new NotSupportedException(SR.GetResourceString(SR.ID0403)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
/// Gets the default descriptor definition assigned to this handler.
|
|
|
@ -1442,24 +1537,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
.Build(); |
|
|
.Build(); |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) |
|
|
public ValueTask HandleAsync(ProcessAuthenticationContext context) => ValueTask.CompletedTask; |
|
|
{ |
|
|
|
|
|
ArgumentNullException.ThrowIfNull(context); |
|
|
|
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
|
|
|
context.MergedPrincipal = context.EndpointType switch |
|
|
|
|
|
{ |
|
|
|
|
|
// When the authentication context is marshalled, restore the merged principal from the other instance.
|
|
|
|
|
|
OpenIddictClientEndpointType.Unknown when _marshal.TryGetResult(context.Nonce, out var notification) |
|
|
|
|
|
=> notification.MergedPrincipal, |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, don't alter the current context.
|
|
|
|
|
|
_ => context.MergedPrincipal |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -1492,8 +1570,13 @@ public static partial class OpenIddictClientSystemIntegrationHandlers |
|
|
|
|
|
|
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
Debug.Assert(!string.IsNullOrEmpty(context.Nonce), SR.GetResourceString(SR.ID4019)); |
|
|
|
|
|
|
|
|
// Inform the marshal that the authentication demand is complete.
|
|
|
if (context.EndpointType is not (OpenIddictClientEndpointType.Redirection or |
|
|
if (!_marshal.TryComplete(context.Nonce, context)) |
|
|
OpenIddictClientEndpointType.PostLogoutRedirection)) |
|
|
|
|
|
{ |
|
|
|
|
|
return ValueTask.CompletedTask; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_marshal.IsTracked(context.Nonce) && !_marshal.TryComplete(context.Nonce, context)) |
|
|
{ |
|
|
{ |
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0380)); |
|
|
throw new InvalidOperationException(SR.GetResourceString(SR.ID0380)); |
|
|
} |
|
|
} |
|
|
|