Open ID Connect issuer URI "cleanup" before discovery breaks issuer URI matching #6377
Labels
in: oauth2
An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
Summary
When doing OpenID Connect issuer discovery, Spring Security removes any trailing slash from the issuer URI before appending
/.well-known/openid-configuration
, as mandated by the spec. However, after having fetched the configuration, the the returned configuration's issuer URI matched against the "cleaned up" version of the issue URI, rather than the the originally provided one.This is problematic if the canonical issuer URI has a trailing space (e.g.,
https://auth.example.com/
).Actual Behavior
Note that the "requested issuer" always lacks the trailing slash, even if it was explicitly specified with trailing slash in the configuration.
Expected Behavior
No error, as the issuer URI returned by the configuration endpoint and the one provided in the application configuration are actually the same.
Details
OAuth2ClientPropertiesRegistrationAdapter.java
has the following code:And in
fromOidcIssuerLocation()
:Because
fromOidcIssuerLocation()
doesn't know about the originally provided issuer URL, it matches against thecleanedIssuer
, which causes the described problem. The easiest way to solve that is to do the cleanup withinfromOidcIssuerLocation()
, which then still has the original version available for matching.The text was updated successfully, but these errors were encountered: