Skip to content

Conversation

@prafsoni
Copy link

@prafsoni prafsoni commented Nov 11, 2025

Resolves #2348

  • Adds support for OAuth2 in spring-cloud-client using spring-security-oauth2-client.
  • Introduces OAuth2 configurations under spring.cloud.config.oauth2.*.
  • OAuth2 Support is disabled (spring.cloud.config.oauth2.enabled: false) by default to maintain existing behavior.
  • Adds spring-cloud-config-client-oauth2-tests module for OAuth2 support integration tests

@prafsoni prafsoni force-pushed the feature/config-client-oauth2-support branch from 2180ae6 to b947caa Compare November 11, 2025 19:51
@prafsoni prafsoni changed the title Feature/config client oauth2 support Add OAuth2 support in spring-config-client Nov 11, 2025

private ClientRegistrationRepository clientRegistrationRepository(
ConfigClientProperties.OAuth2Properties properties) {
OAuth2ClientProperties oauth2ClientProperties = new OAuth2ClientProperties();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think we would just use the existing properties
https://docs.spring.io/spring-security/reference/servlet/oauth2/login/core.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I took this approach for a few reasons.

  • First, to keep things isolated and not depend on Spring Security autoconfiguration, reuse the classes provided and imitate the same here.
  • Additionally, I am not sure about how it would work, as this initialization happens so early in the app lifecycle.
  • Also, there are scenarios where configserver would actually serve the spring.security.oauth2.client.*


List<ClientRegistration> registrations = new ArrayList<>(
new OAuth2ClientPropertiesMapper(oauth2ClientProperties).asClientRegistrations().values());
return new InMemoryClientRegistrationRepository(registrations);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need to be configurable. Maybe by default we use InMemoryClientRegistrationRepository but this should be a bean that can be supplied

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if there is a usecase for this, as things are a bit tricky to wire things in with all BootstrapRegistryInitializer. If I could get a little more context on what is required I could try to address this

@ryanjbaxter
Copy link
Contributor

Thanks. I will need to set aside some time to deep dive on this after our GA release.

Also would love @jgrandja to take a look as well.

@prafsoni
Copy link
Author

Thanks. I will need to set aside some time to deep dive on this after our GA release.

Also would love @jgrandja to take a look as well.

@ryanjbaxter Thanks for the review. Since the changes are not disruptive. So, I was hoping this would make it to 5.0.0. I do understand this is a bit of an ask given that GA is so close. If there is something I could do to make it a possibility, please do let me know.

@spencergibb
Copy link
Member

So, I was hoping this would make it to 5.0.0. I do understand this is a bit of an ask given that GA is so close. If there is something I could do to make it a possibility, please do let me know.

The RC1 release is already in progress and everyone is focused on that and then the GA after. It will have to wait, I'm afraid.

@ryanjbaxter
Copy link
Contributor

If I have some time I will take a look at it but as Spencer said we have a lot on our plate between now and GA and we don't want to rush this, we want to make sure we get it right.

Unfortunately this major has been a challenge for the Spring Cloud team as we try to keep up with the incoming changes from Spring Boot and Spring Framework. We did not have as much time as we would have liked to put in new features into Spring Cloud.

@jgrandja
Copy link

@prafsoni I took a look at the PR and it introduces the password grant, which has been removed in OAuth 2.1, as well as Spring Security 7.0. This will need to get addressed when we revisit the PR after the majors are out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide support for OAuth2 in Spring Config Client.

5 participants