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.
Comment From: jzheaux
@christophejan thanks for the report.
To make sure we're on the same page, would you be able to provide a minimal GitHub sample that demonstrates the arrangement you are describing?
Comment From: christophejan
Thank you very much @jzheaux for your interest.
Here a minimal sample : https://github.com/christophejan/spring-security-issue-9293