liveBook · Manning

Chapter 17: Implementing security in reactive applications

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

The introduction explains why reactive programming can help with divisible tasks and why securing reactive applications requires a different Spring Security approach.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why reactive programming can help with divisible tasks and why securing reactive applications requires a different Spring Security approach.

Key terms: reactive programming, imperative approach, subtasks, application-level security, reactive apps, Spring Security

17.1 What are reactive apps?

The section introduces reactive data processing and explains why its execution model affects Spring Security configurations.

Key terms: imperative approach, reactive approach, Publisher, Subscriber, Project Reactor, Mono, Flux, SecurityContext, ThreadLocal, Authentication

17.2 User management in reactive apps

This section shows how reactive Spring Security retrieves users, authenticates requests, and makes authentication details available to application code.

Key terms: ReactiveUserDetailsService, Mono<UserDetails>, MapReactiveUserDetailsService, PasswordEncoder, AuthenticationWebFilter, ReactiveAuthenticationManager, Mono<Authentication>, ReactiveSecurityContextHolder, SecurityContext, ThreadLocal

17.3 Configuring authorization rules in reactive apps

The section places authorization after authentication in a reactive app and introduces the need to configure authorization rules.

Key terms: authentication, authorization, SecurityContext

17.3.1 Applying authorization at the endpoint layer in reactive apps

This section shows how to configure endpoint authorization in reactive Spring Security apps, including standard rules, custom access decisions, and the components that enforce them.

Key terms: SecurityWebFilterChain, SecurityFilterChain, ServerHttpSecurity, build(), authorizeExchange(), pathMatchers(), authenticated(), permitAll(), anyExchange(), access()

17.3.2 Using method security in reactive apps

This section shows how to enable reactive method security, apply a role-based rule with @PreAuthorize, and understand why a request that fails the rule is denied.

Key terms: reactive method security, method level, endpoint layer, @EnableReactiveMethodSecurity, @PreAuthorize, SpEL, aspect, preauthorization rules, HTTP 403 Forbidden

17.4 Creating a reactive OAuth 2 resource server

This section configures a reactive OAuth 2 resource server to validate JWT access tokens and shows how to call an endpoint with a token from an authorization server.

Key terms: SecurityWebFilterChain, oauth2ResourceServer(), jwt(), Customizer, public key, token signature validation, publicKey(), jwtSpec, access token, authorization server

17.5 Summary

Concepts explained in this chapter

← Chapter 16: Implementing an OAuth 2 client Chapter 18: Testing security configurations →

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.