diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs index 8d2b8609a..0aec45cb9 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs @@ -22,6 +22,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers /* * Authentication processing: */ + DisableIssuerParameterValidation.Descriptor, ValidateRedirectionRequestSignature.Descriptor, HandleNonStandardFrontchannelErrorResponse.Descriptor, ValidateNonStandardParameters.Descriptor, @@ -68,6 +69,45 @@ public static partial class OpenIddictClientWebIntegrationHandlers .. UserInfo.DefaultHandlers ]; + /// + /// Contains the logic responsible for disabling the issuer parameter validation for the providers that require it. + /// + public sealed class DisableIssuerParameterValidation : IOpenIddictClientHandler + { + /// + /// Gets the default descriptor definition assigned to this handler. + /// + public static OpenIddictClientHandlerDescriptor Descriptor { get; } + = OpenIddictClientHandlerDescriptor.CreateBuilder() + .UseSingletonHandler() + .SetOrder(ValidateIssuerParameter.Descriptor.Order - 500) + .SetType(OpenIddictClientHandlerType.BuiltIn) + .Build(); + + /// + public ValueTask HandleAsync(ProcessAuthenticationContext context) + { + ArgumentNullException.ThrowIfNull(context); + + context.DisableIssuerParameterValidation = context.Registration.ProviderType switch + { + // Google is currently rolling out a change that causes the "iss" authorization response + // parameter to be returned without the "authorization_response_iss_parameter_supported" + // flag being advertised in the provider metadata. Since OpenIddict rejects authorization + // responses that contain an issuer if "authorization_response_iss_parameter_supported" is + // not explicitly set to true, validation must be disabled until the deployment is complete. + // + // See https://github.com/openiddict/openiddict-core/issues/2428 for more information. + ProviderTypes.Google when context.Request.HasParameter(Parameters.Iss) && + context.Configuration.AuthorizationResponseIssParameterSupported is not true => true, + + _ => context.DisableIssuerParameterValidation + }; + + return ValueTask.CompletedTask; + } + } + /// /// Contains the logic responsible for validating the signature or message authentication /// code attached to the redirection request for the providers that require it. diff --git a/src/OpenIddict.Client/OpenIddictClientEvents.cs b/src/OpenIddict.Client/OpenIddictClientEvents.cs index e01e8d95f..1610d433b 100644 --- a/src/OpenIddict.Client/OpenIddictClientEvents.cs +++ b/src/OpenIddict.Client/OpenIddictClientEvents.cs @@ -1012,6 +1012,14 @@ public OpenIddictRequest Request /// public bool DisableFrontchannelIdentityTokenNonceValidation { get; set; } + /// + /// Gets or sets a boolean indicating whether issuer parameter validation should be disabled. + /// + /// + /// Note: overriding the value of this property is generally not recommended. + /// + public bool DisableIssuerParameterValidation { get; set; } + /// /// Gets or sets a boolean indicating whether userinfo retrieval should be disabled. /// diff --git a/src/OpenIddict.Client/OpenIddictClientExtensions.cs b/src/OpenIddict.Client/OpenIddictClientExtensions.cs index a16a3a79e..af687e838 100644 --- a/src/OpenIddict.Client/OpenIddictClientExtensions.cs +++ b/src/OpenIddict.Client/OpenIddictClientExtensions.cs @@ -50,6 +50,7 @@ public static OpenIddictClientBuilder AddClient(this OpenIddictBuilder builder) builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); + builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); diff --git a/src/OpenIddict.Client/OpenIddictClientHandlerFilters.cs b/src/OpenIddict.Client/OpenIddictClientHandlerFilters.cs index 5d1233174..9f2e7fc31 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlerFilters.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlerFilters.cs @@ -266,6 +266,20 @@ public ValueTask IsActiveAsync(ProcessAuthenticationContext context) } } + /// + /// Represents a filter that excludes the associated handlers if issuer parameter validation was disabled. + /// + public sealed class RequireIssuerParameterValidationEnabled : IOpenIddictClientHandlerFilter + { + /// + public ValueTask IsActiveAsync(ProcessAuthenticationContext context) + { + ArgumentNullException.ThrowIfNull(context); + + return new(!context.DisableIssuerParameterValidation); + } + } + /// /// Represents a filter that excludes the associated handlers if the selected token format is not JSON Web Token. /// diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.cs index d3feab31c..0b2c8906f 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.cs @@ -1171,6 +1171,7 @@ public sealed class ValidateIssuerParameter : IOpenIddictClientHandler public static OpenIddictClientHandlerDescriptor Descriptor { get; } = OpenIddictClientHandlerDescriptor.CreateBuilder() + .AddFilter() .AddFilter() .UseSingletonHandler() .SetOrder(ResolveClientRegistrationFromStateToken.Descriptor.Order + 1_000)