UserDetailsService
UserDetailsService is a Spring Security interface for retrieving user-specific data required during authentication.
Spring Security in Action, Second Edition
UserDetailsService is a Spring Security interface for retrieving user-specific data needed to authenticate a user.
- How it is used
- Retrieves user details for AuthenticationProvider during Spring Security authentication.
- How deep it goes
- Defines the single retrieval method, custom implementations, provided implementations, registration, and testing, while deferring password encoding details.
- Examples
- Uses in-memory users, a custom list-backed service, curl requests, and @WithUserDetails integration tests.
- What you can do after
- Builds or configures a user-details provider and tests authentication against an endpoint.
Read how Spring Security in Action, Second Edition explains UserDetailsService →
Spring in Action, Sixth Edition
UserDetailsService is a Spring Security interface that retrieves user-specific authentication details synchronously.
- How it is used
- Configures authentication by supplying Spring Security with user-specific details through a UserDetailsService bean.
- How deep it goes
- Defines the one-method contract and demonstrates in-memory and repository-backed implementations with missing-user handling.
- Examples
- Uses in-memory users named buzz and woody, then demonstrates a Taco Cloud database lookup through UserRepository.
- What you can do after
- Build it from scratch by declaring an in-memory or repository-backed UserDetailsService bean.
Read how Spring in Action, Sixth Edition explains UserDetailsService →
Also covered in
What to know first
- authorizationAuthorization is the determination of which actions or resources an identity or other entity is permitted to access under defined permissions or policies.
Related concepts
- AuthenticationProviderused by · AuthenticationProvider is a Spring Security interface or component that encapsulates a specific authentication mechanism and returns an authentication result.
- functional interfacekind of · A functional interface is an interface with exactly one abstract operation, making it compatible with implementation by a function, lambda expression, or method reference.
- InMemoryUserDetailsManagerimplemented by · InMemoryUserDetailsManager is a Spring Security UserDetailsService and UserDetailsManager implementation that stores user details in application memory.
- loadUserByUsernamehas part · loadUserByUsername is the UserDetailsService operation that retrieves the security information associated with a specified username.
- ReactiveUserDetailsServiceequivalent to · ReactiveUserDetailsService is a Spring Security interface for asynchronously retrieving user details used in authentication.
- UserDetailsManagerincludes · UserDetailsManager is a Spring Security interface that extends UserDetailsService with operations for creating users and modifying or deleting user passwords.
Questions about UserDetailsService
What is UserDetailsService?
UserDetailsService is a Spring Security interface for retrieving user-specific data required during authentication.
Which Manning books explain UserDetailsService?
Spring Security in Action, Second Edition and Spring in Action, Sixth Edition.
What should I know before learning UserDetailsService?
Manning books that teach UserDetailsService usually introduce authorization first.
What kinds of UserDetailsService are there?
Kinds of UserDetailsService include UserDetailsManager.
What is UserDetailsService a kind of?
UserDetailsService is a kind of functional interface. A functional interface is an interface with exactly one abstract operation, making it compatible with implementation by a function, lambda expression, or method reference.
What are the parts of UserDetailsService?
UserDetailsService includes loadUserByUsername.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

