liveBook · Manning

Chapter 9: Configuring CSRF protection

What you will learn in chapter 9 of Spring Security in Action, Second Edition

Introduces the risk of CSRF attacks and explains why Spring Security’s default CSRF protection affected earlier HTTP POST examples.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces the risk of CSRF attacks and explains why Spring Security’s default CSRF protection affected earlier HTTP POST examples.

Key terms: CSRF, cross-site request forgery, HTTP POST, CSRF protection

9.1 How CSRF protection works in Spring Security

The section explains how CSRF attacks exploit a logged-in user, how Spring Security checks CSRF tokens, and how a small example makes that behavior visible.

Key terms: CSRF attacks, forgery code, CSRF token, mutating operations, CsrfFilter, CsrfTokenRepository, HTTP session, HTTP 403 Forbidden, _csrf, CsrfToken

9.2 Using CSRF protection in practical scenarios

This section shows when CSRF protection fits a web application and how a browser form must send a token for a mutating request to succeed.

Key terms: CSRF protection, CSRF tokens, mutating operations, default form login, CSRF token, hidden input, HTTP POST, HTTP 403 Forbidden, CsrfFilter, _csrf

9.3 Customizing CSRF protection

This section shows how to exempt selected requests from CSRF protection and replace session-based token storage with a database-backed implementation.

Key terms: csrf(), Customizer, ignoringRequestMatchers(), RequestMatcher, MvcRequestMatcher, HTTP session, horizontal scaling, client ID, session ID, CsrfToken

9.4 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 8: Configuring endpoint-level authorization: Applying restrictions Chapter 10: Configuring CORS →

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.