spring-projects / spring-projects/spring-security

InitializeUserDetailsManagerConfigurer inconsistent with UserDetailsService shared object ?

Open
#9,293 2 comments 0 reactions 1 assignee View on GitHub

@jzheaux is already working on this.

Since Dec 18, 2020.

in: config type: bug
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Describe the bug
When a UserDetailsService bean is found by InitializeUserDetailsBeanManagerConfigurer, a DaoAuthenticationProvider is automatically add to the AuthenticationManagerBuilder but the UserDetailsService object shared by WebSecurityConfigurerAdapter doesn't delegate to the UserDetailsService bean found and throw "UserDetailsService is required." when used.

To Reproduce
Define :

  • a WebSecurityConfigurerAdapter that apply a configurer that use UserDetailsService shared object
  • a UserDetailsService bean (without specifying it in WebSecurityConfigurerAdapter)

Expected behavior
I think UserDetailsService shared object should take in account the UserDetailsService used by the AuthenticationManager.

More details
This behavior seems to be caused by InitializeUserDetailsBeanManagerConfigurer that use AuthenticationManagerBuilder#authenticationProvider method to add the DaoAuthenticationProvider instead of using DaoAuthenticationConfigurer.
As describe in these methods, that affect the getDefaultUserDetailsService method that is used by UserDetailsServiceDelegator.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.