With a Spring Boot client configured in the DMZ and Spring Security OAuth configured using:
issuer-uri: https://authentication_server/auth/realms/my-realm
I get this error from Spring Security:
The Issuer "https://external_url/auth/realms/my-realm" provided in the configuration metadata did not match the requested issuer "https://authentication_server/auth/realms/my-realm
From this post I have learned that I need to specify authorization-uri
, token-uri
and jwk-set-uri
instead of issuer-uri
, and then it also works.
authorization-uri: https://external_url/auth/realms/my-realm/protocol/openid-connect/auth
token-uri: https://authentication_server/auth/realms/my-realm/protocol/openid-connect/token
jwk-set-uri: https://authentication_server/auth/realms/my-realm/protocol/openid-connect/certs
(I do not get why Spring Security cannot auto-configure with the same values from the issuer-uri
when it works setting the values individually)
Now the problem is that logout stops working. When using issuer-uri
the OAuth is auto-configured and end_session_endpoint
is fetched from the answer, but when specifying each setting there is no way to specify the end_session_endpoint
.
Is this an outstanding issue in Spring Security OAuth, or do I need to configure it differently?
I had to make a work around for this. With little time I started by copying the existing OidcClientInitiatedLogoutSuccessHandler which I already were using in configuring LogoutRedirectUri.
I simply copied the class and changed the implementation of the method endSessionEndpoint()
to return the URI which is returned by our OAuth server as end_session_endpoint
.
This issue is tracked in spring-security GitHub. Probable fix will be allowing to add "Additional attributes for ClientRegistration and ProviderDetails".