ClientRegistrations class's OpenID Provider Configuration Validation does not conform to specification #16460
Labels
in: oauth2
An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
status: feedback-reminder
We've sent a reminder that we need additional information before we can continue
status: waiting-for-feedback
We need additional information before we can continue
type: bug
A general bug
Describe the bug
The section 4.3 in the OpenID Connect Discovery specification says "the Issuer URL that was used as the prefix to /.well-known/openid-configuration". However, the validation in
ClientRegistrations.class
does anequal()
comparison of the entire issuer URL which is comparing too much because a provider's Issuer URL might contain additional parameters.For example, in Azure AD B2C multiple OIDC configurations could be using the same Issuer and configuration URL in Azure AD B2C is not an straightforward URL. An additional parameter
p
is added at the end to identify which configurations you want to retrieve.Usual Provider:
Azure AD B2C:
To Reproduce
Follow the procedure at https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory-b2c-oidc
Because the well known uri is
https://eaxmple.b2clogin.com/00000000-0000-0000-00000000-000000000000/v2.0/.well-known/openid-configuration?p=b2c_1_policy_name_a
, this Issuer URL must be configurated with additional?p=b2c_1_policy_name_a
at the end.The following exception will be thrown during start up.
The exception was due to this method is comparing
https://eaxmple.b2clogin.com/00000000-0000-0000-00000000-000000000000/v2.0/
(metadata.getIssuer().getValue()
) andhttps://eaxmple.b2clogin.com/00000000-0000-0000-00000000-000000000000/v2.0/?p=b2c_1_policy_name_a
(issuer
).Expected behavior
The validation should be validating whether the
issuer
value from well known configuration is the prefix of Issuer URL.defined in
spring.security.oauth2.client.provider.b2c.issuer-uri=
without taking into account of additional query string parameters .Possible Solution
I've tested in my local that using
issuer.startsWith(metadataIssuer)
instead ofissuer.equals(metadataIssuer)
could avoid the issue and it seems more conform to the specification as in "the Issuer URL that was used as the prefix to /.well-known/openid-configuration".e.g.
The text was updated successfully, but these errors were encountered: