There is a newer version available. Please update to Spring Security 5.6!

UserDetailsService

{security-api-url}org/springframework/security/core/userdetails/UserDetailsService.html[UserDetailsService] is used by DaoAuthenticationProvider for retrieving a username, password, and other attributes for authenticating with a username and password. Spring Security provides in-memory and JDBC implementations of UserDetailsService.

You can define custom authentication by exposing a custom UserDetailsService as a bean. For example, the following will customize authentication assuming that CustomUserDetailsService implements UserDetailsService:

This is only used if the AuthenticationManagerBuilder has not been populated and no AuthenticationProviderBean is defined.
Example 1. Custom UserDetailsService Bean
Java
@Bean
CustomUserDetailsService customUserDetailsService() {
	return new CustomUserDetailsService();
}
XML
<b:bean class="example.CustomUserDetailsService"/>
Kotlin
@Bean
fun customUserDetailsService() = CustomUserDetailsService()