-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Expose property to configure configurationMetadata on an OAuth2 ClientRegistration #21375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am going to revert this change. After speaking with @jgrandja, it's become clear that @nagaraj-pattar Our guess as to why you need to explicitly set the |
I faced few issues with issuer mismatch. If the issuer has mismatched, then those clients registrations were rejected by spring boot and application was not starting up. In such scenarios these properties will be useful to read client configuration from properties. There are already place holders for other URIs, hence, it is wise to expose these properties. |
Issuer mismatch sounds like some sort of misconfiguration. Configuring the configuration metadata manually is not what a majority of users would do and we don't want to expose a property that would let them do that. Like I said, if you must configure it manually, you can create your own If you have any more questions please ask them on Gitter. Spring Security's Gitter might be a better place to ask anything about issuer mismatch or configurationMetadata. |
Manual metadata configuration has one advantage. Actually this is the reason why I configured the metadata manually and stumbled over this issue. @mbhave Is this decision final? |
@dawi As mentioned in the comment above, if you must configure the metadata manually, you can do so by creating your own |
Coming back to this. Unless there is a strong reason for not allowing additional configuration after OpenID Connect discovery I think that Boot could offer the ability to set additional metadata properties that the provider doesn't offer configuration for. This would facilitate the case where the user (client) wants to be able to use discovery but is working with a provider that does not allow them to set the For example, after working with a provider that does not offer the configuration of the I'd propose that Spring Boot could offer a way, via properties, to specify additional This seems related to the following two previous issues that I came across in my search for a solution Also, the other way I've solved for this is to set up a |
What's your take on this please, @jgrandja? |
@mbhave I disagree with Issuer mismatch always being a sort of misconfiguration. There are justified cases in which the issuer might mismatch. For example, I might use subdomains for each application Identity manager and this leads to a mismatch: {
"issuer":"https://identity.mydomain.com/",
"authorization_endpoint":"https://identity-1238751009726.identity.mydomain.com/oauth2/v1/authorize",
"token_endpoint":"https://identity-1238751009726.identity.mydomain.com/oauth2/v1/token",
...
} This setup works on other frameworks, I can't find a reason why it shouldn't on spring. I think there should be either an option to allow mismatches or at least an option to load all metadata manually. #21375 (comment) @adase11 That sounds definitely like a hack. The fact is, OidcClientInitiatedLogoutSuccessHandler exists specifically for that exact purpose but it cannot be used if end_session_endpoint is not set, which can happen for a myriad of reasons. I don't see the point on supporting this many property mappings, if they're not complete and actively make functionality unavailable. |
I'm curious, why doesn't the provider return the specific configuration metadata? It looks like you are referring to However, since you're looking to set this manually, it appears that the provider does in fact support the Logout Endpoint? If this is the case, then the Provider should be configured correctly to return What provider are you using? Are you able to configure it or is this managed by another team? |
Please review the spec at 4.3. OpenID Provider Configuration Validation:
FYI, this validation check lives in Spring Security ( I understand your environment is using subdomains for each issuer (very common), however, this is still an environment related issue and should be addressed there. |
@jgrandja Here's Google's documentation around OIDC discovery which points to their .well-known/openid-configuration from accounts.google.com that doesn't contain the Another one I've seen more details on is Auth0. Auth0 doesn't allow users to configure the For what it's worth, I definitely hear the argument that the Boot shouldn't have to account for providers that are non compliant to the spec |
Missing ability to override a couple of additional properties requires copying a very big chunk of code which handles all the configuration properties under In my case OIDC provider is compliant but it is served via a reverse proxy which is not ready at the moment of Spring app configuration and it makes impossible to fetch from issuer-uri. And that's ridiculous that it's not possible to provide the data from |
@pelepelin can you please describe your use case in some more detail? Specifically, it would be useful to know exactly what additional configuration you would like to be able to provide and why that's necessary when working with a compliant OIDC provider. Also, where does the reverse proxy fit in and how does that adversely affect things? |
@wilkinsona Generally it's similar to the last linked ticket spring-projects/spring-security#14257
So in the end I followed https://docs.spring.io/spring-security/reference/reactive/oauth2/login/core.html#webflux-oauth2-login-register-reactiveclientregistrationrepository-bean and it's not so much code but I was disappointed that I can't use spring-boot configuration properties provided out of the box (and might miss something configuring the client with my code). |
Thanks, @pelepelin. WDYT of this use case, @jgrandja? |
In my case : We have lot of OIDC providers, some are managed by our organization, and other are provided by our customer. Configuring issuer uri work, but : if only one provider is down, Spring application will not start. |
I'd like to see the code duplication your application is requiring. Can you please put together a minimal sample demonstrating where you are needing to copy code and we'll see what we can do to help reduce it. Feel free to use the Spring Authorization Server Demo Sample as a starting point. |
@jgrandja I'm afraid a self-containing sample for my use case would involve a docker-compose, gateway service and keycloak as an identity provider. However, for my sentence the configuration bean below is enough, companion custom properties class is obvious. This is effectively a specialized version of OAuth2ClientPropertiesMapper with the difference that it sets some more properties, notably (up: fixed) it sets @Configuration
@AllArgsConstructor
public class OAuth2Config {
@NonNull
SecurityProperties securityProperties;
@Bean
public ReactiveClientRegistrationRepository clientRegistrationRepository() {
return new InMemoryReactiveClientRegistrationRepository(this.clientRegistration());
}
private ClientRegistration clientRegistration() {
OAuth2Client props = securityProperties.oauth2Client();
return ClientRegistration.withRegistrationId(props.registrationId())
.clientId(props.clientId())
.clientSecret(props.clientSecret())
.clientName(props.clientName())
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.redirectUri("{baseUrl}" + securityProperties.authorizationCallbackPath())
.scope(props.scope())
.userNameAttributeName(props.userNameAttribute())
.issuerUri(props.issuer().toASCIIString())
.authorizationUri(props.authorizationEndpoint().toASCIIString())
.tokenUri(props.tokenEndpoint().toASCIIString())
.userInfoUri(props.userinfoEndpoint().toASCIIString())
.jwkSetUri(props.jwksUri().toASCIIString())
.providerConfigurationMetadata(Map.of(
"end_session_endpoint", props.endSessionEndpoint().toASCIIString()
))
.build();
}
} |
The class org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties.Provider is required to have the following
Due to this missing code, we are unable to configure additional metadata configuration like
"end_session_endpoint".
Request you to make this fix so that client registration defined in the application.properties / application.yml file can be configured with additional metadata and OidcClientInitiatedLogoutSuccessHandler can consume this metadata.
The text was updated successfully, but these errors were encountered: