Book Image

Hands-On Spring Security 5 for Reactive Applications

By : Tomcy John
Book Image

Hands-On Spring Security 5 for Reactive Applications

By: Tomcy John

Overview of this book

Spring Security enables developers to seamlessly integrate authorization, authentication, and a range of security features for complex enterprise applications. This book provides a hands-on approach to developing reactive applications using Spring and will help you get up and running in no time. Complete with step-by-step explanations, practical examples, and self-assessment questions, the book begins by explaining the essential concepts of reactive programming, Spring Framework, and Spring Security. You’ll then learn about a variety of authentication mechanisms and how to integrate them easily with a Spring MVC application. You’ll also understand how to achieve authorization in a Spring WebFlux application using Spring Security. Furthermore, the book will take you through the configuration required to implement OAuth2 for securing REST APIs, and guide you in integrating security in microservices and serverless applications. Finally, you’ll be able to augment add-ons that will enhance any Spring Security module. By the end of the book, you’ll be equipped to integrate Spring Security into your Java enterprise applications proficiently.
Table of Contents (15 chapters)
Title Page
Copyright and Credits
Packt Upsell

Session management

Spring Security allows you to manage sessions on your server with only some configuration. Some of the most important session management activities are listed here:

  • Session creation: This decides when a session needs to be created and the ways in which you can interact with it. In the Spring Security configuration, put in the following code:

There are four session creation policies that you can choose from. They are as follows:

    • ALWAYS: Always create a session if it doesn't exist.
    • IF_REQUIRED: If required, a session is created.
    • NEVER: This will never create a session; rather, it will use the session if it exists.
    • STATELESS: No session will be created nor used.
    • invalidSession: This controls how the user is intimated if the server sees an invalid session:
  • Session timeout: This controls how the user is intimated if the session has expired.
  • Concurrent...