liveBook · Manning

Form-based login

As explained in Spring Security in Action, Second Edition

Form-based login is an authentication method in which a user submits credentials through an application-provided login form.

Form-based login authenticates web users through an application-provided credential form. In Spring Security, enabling formLogin() redirects unauthenticated requests to a login page, then permits access after successful authentication. section 6.3.2

A minimal protected Spring MVC application typically follows this sequence:

  • Let Spring Security provide the login and logout pages automatically. section 6.3.2

Default destination after login

Set defaultSuccessUrl("/home", true) to send a successfully authenticated user to the application's home page. For more conditional behavior, a success handler can inspect authorities and redirect users with read access to /home and others to /error.

How Spring Security in Action, Second Edition covers it

How deep it goes
Explains default configuration, MVC integration, redirects, custom handlers, and combined HTTP Basic support; defers scalable security-context storage to later treatment.
Examples
Uses a /home controller, auto-configured login and logout pages, default-success redirects, authority-based handlers, and curl with HTTP Basic.
What it assumes
Assumes basic Spring and Java knowledge while building on UserDetailsService, PasswordEncoder, AuthenticationProvider, AuthenticationManager, and SecurityContext.
What you can do after
Apply it via Spring Security by configuring SecurityFilterChain, protecting requests, and customizing authentication success or failure behavior.
How it connects
Connects form-based login with Spring Security, SecurityContext, server-side sessions, Spring MVC, HTTP Basic, and authentication handlers.

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.