liveBook · Manning

UserDetails

As explained in Spring in Action, Sixth Edition

UserDetails is a Spring Security interface that exposes a user's credentials, authorities, and account-status information to the security framework.

UserDetails is the Spring Security contract that lets a user object provide credentials, granted authorities, and account-status information to the framework. section 5.2.2

A UserDetails implementation supplies:

  • getAuthorities(), which returns the user's granted authorities. section 5.2.2
  • isEnabled(), isAccountNonLocked(), and related methods, which report whether the account remains active. section 5.2.2
  • Credentials and profile data, allowing one application entity to support authentication and application needs. section 5.2.2

A database-backed user

A Taco Cloud User entity implements UserDetails, returns ROLE_USER from getAuthorities(), and currently returns true from its account-status methods. A custom UserDetailsService finds that entity by username and returns it to Spring Security. section 5.2.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Defines authorities, credentials, and account-status methods through a concrete entity implementation.
Examples
Uses a Taco Cloud User entity, ROLE_USER authority, active-account booleans, and username-based repository lookup.
What it assumes
Builds on a User entity and UserRepository capable of finding users by username.
What you can do after
Apply via a UserDetails implementation and custom UserDetailsService that return database-backed users to Spring Security.
How it connects
Ties user entities to UserDetailsService, UserRepository, GrantedAuthority, and Spring Data JPA.

Also explained in

Compare how 2 books explain UserDetails →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.