liveBook · Manning

Authentication filter

As explained in Spring Security in Action, Second Edition

An authentication filter is a request-processing component that intercepts authentication requests and delegates them to an authentication mechanism.

An authentication filter intercepts an authentication request and delegates it to the authentication manager. The manager uses an authentication provider, which applies the authentication logic and returns a response that the filter uses to configure the security context. section 2.2

The authentication flow connects these responsibilities:

  • The authentication manager coordinates authentication processing. section 2.2
  • The authentication provider implements the authentication logic, using UserDetailsService for user management and PasswordEncoder for password management. section 2.2
  • The security context retains authentication data until the action ends, usually until a thread-per-request application sends its response. section 2.2

Authenticated endpoint request

A request such as `curl -k -u user:93a01cf0-794b-4b98-86ef-54860f36f7f3 https://localhost:8080/hello` supplies credentials for a protected endpoint and receives `Hello!` after successful authentication. section 2.2

Figure 2.2 The core elements involved in Spring Security’s authentication process and their interconnections are the focus here. This framework forms the essential structure for executing authentication using Spring Security. Throughout the book, we will frequently reference this architecture while examining various authentication and authorization strategies.

Use the architecture diagram to trace the authentication filter’s relationships with the authentication manager, provider, user details service, password encoder, and security context. section 2.2

How Spring Security in Action, Second Edition covers it

How deep it goes
Explains delegation and component relationships, but stops short of filter implementation details.
Examples
Uses a curl request with credentials to access a protected Spring endpoint.
What you can do after
Evaluate how Spring Security routes credentials through authentication components and retains the resulting authentication.
How it connects
Connects authentication manager, authentication provider, UserDetailsService, PasswordEncoder, and security context.

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.