For the latest stable version, please use Spring Security 6.4.1! |
UserDetailsService
UserDetailsService
is used by DaoAuthenticationProvider
for retrieving a username, a 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 listing customizes authentication, assuming that CustomUserDetailsService
implements UserDetailsService
:
This is only used if the |
Custom UserDetailsService Bean
-
Java
-
XML
-
Kotlin
@Bean
CustomUserDetailsService customUserDetailsService() {
return new CustomUserDetailsService();
}
<b:bean class="example.CustomUserDetailsService"/>
@Bean
fun customUserDetailsService() = CustomUserDetailsService()