liveBook · Manning

Spring Security User

As explained in Spring Security in Action, Second Edition

User is a Spring Security class representing an authenticated user's username, password, and authorities.

Spring Security’s User class represents an application user with a username, password, and at least one authority. Authorities identify actions the user may perform. Spring Boot supplies security defaults, while application code can define users explicitly. section 2.4

Use User with the surrounding authentication components:

  • Store users in application memory with InMemoryUserDetailsManager. section 2.4
  • Supply a PasswordEncoder for password handling; NoOpPasswordEncoder keeps passwords in cleartext and suits learning examples, not production. section 2.4
  • Connect custom authentication logic through AuthenticationProvider when the standard arrangement is insufficient. section 2.4

A small in-memory user setup

Create a User with a username, password, and authority, then add it to an InMemoryUserDetailsManager. This provides a compact setup for learning authentication and authorization behavior before replacing the in-memory store or password handling. section 2.4

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines required user data and neighboring components, but does not descend into User implementation internals.
Examples
Uses in-memory users with usernames, passwords, authorities, and the cleartext NoOpPasswordEncoder.
What you can do after
Configure in-memory authenticated users with User and InMemoryUserDetailsManager for learning examples or proofs of concept.
How it connects
Connects users with UserDetailsService, InMemoryUserDetailsManager, PasswordEncoder, AuthenticationProvider, authentication, and authorization.

Related concepts

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