Skip to content

Even when spring.security.user.name or spring.security.user.password has been configured, user details auto-configuration still backs off when resource server is on the classpath  #38864

@rozagerardo

Description

@rozagerardo

We've introduced the following feature with Boot 3.2:

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#auto-configured-user-details-service

Auto-configured User Details Service

The auto-configured InMemoryUserDetailsManager now backs off when one or more of spring-security-oauth2-client, spring-security-oauth2-resource-server, and spring-security-saml2-service-provider is on the classpath. Similarly, in reactive applications, the auto-configured MapReactiveUserDetailsService now backs off when one or more of spring-security-oauth2-client and spring-security-oauth2-resource-server is one the classpath.

If you are using one of the above dependencies yet still require an InMemoryUserDetailsManager or MapReactiveUserDetailsService in your application, define the required bean in your application.

Since spring-security-oauth2-authorization-server brings the spring-security-oauth2-resource-server as one of its dependencies, the default User Details Service backs off and the login authentication method fails with the minimal configuration suggested by the AS docs (here).

IMO it's expected and desirable (for a minimal configuration, of course) that a user can log in using the user/password authentication method to grant access to the OAuth2 Client to its resources.

So, I'd personally change the feature behavior to back off the default InMemoryUserDetailsManager for the conditions given above, and if the spring-security-oauth2-resource-server is not present in the dependencies.

Let me know what you think. This has also been reported as an Spring Authorization Server issue:

spring-projects/spring-authorization-server#1475

I guess before they can act upon this, it's on the Spring Boot's project to decide whether the default behavior should accommodate to the Spring AS minimal config (as I suggested above), or if it's ok as it is, and the Spring AS has to modify the minimal config guidelines, instructing to define a InMemoryUserDetailsManager bean in the context as well.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions