Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Spring Security
  • Table Of Contents Toc
  • Feedback & Rating feedback
Spring Security

Spring Security

By : Badr Nasslahsen
5 (4)
close
close
Spring Security

Spring Security

5 (4)
By: Badr Nasslahsen

Overview of this book

With experienced hackers constantly targeting apps, properly securing them becomes challenging when you integrate this factor with legacy code, new technologies, and other frameworks. Written by a Lead Cloud and Security Architect as well as CISSP, this book helps you easily secure your Java apps with Spring Security, a trusted and highly customizable authentication and access control framework. The book shows you how to implement different authentication mechanisms and properly restrict access to your app. You’ll learn to integrate Spring Security with popular web frameworks like Thymeleaf and Microservice and Cloud services like Zookeeper and Eureka, along with architecting solutions that leverage its full power while staying loosely coupled. You’ll also see how Spring Security defends against session fixation, moves into concurrency control, and how you can use session management for administrative functions. This fourth edition aligns with Java 17/21 and Spring Security 6, covering advanced security scenarios for RESTful web services and microservices. This ensures you fully understand the issues surrounding stateless authentication and discover a concise approach to solving those issues. By the end of this book, you’ll be able to integrate Spring Security 6 with GraalVM native images seamlessly, from start to finish.
Table of Contents (28 chapters)
close
close
Free Chapter
1
Part 1: Fundamentals of Application Security
5
Part 2: Authentication Techniques
11
Part 3: Exploring OAuth 2 and SAML 2
14
Part 4: Enhancing Authorization Mechanisms
18
Part 5: Advanced Security Features and Deployment Optimization

What this book covers

Chapter 1, Anatomy of an Unsafe Application, covers a hypothetical security audit of our calendar application, illustrating common issues that can be resolved through the proper application of Spring Security. You will learn about some basic security terminology and review some prerequisites for getting the sample application up and running.

Chapter 2, Getting Started with Spring Security, demonstrates the "Hello World" installation of Spring Security. After that, the chapter walks you through some of the most common customizations of Spring Security.

Chapter 3, Custom Authentication, incrementally explains Spring Security’s authentication architecture by customizing key pieces of the authentication infrastructure to address real-world problems. Through these customizations, you will gain an understanding of how Spring Security authentication works and how you can integrate with existing and new authentication mechanisms.

Chapter 4, JDBC-based Authentication, covers authenticating against a database using Spring Security’s built-in Java Database Connectivity (JDBC) support. We then discuss how we can secure our passwords using Spring Security’s new cryptography module.

Chapter 5, Authentication with Spring Data, looks at the Spring Data project, and how to leverage Jakarta Persistence (JPA) to perform authentication against a relational database. We will also explore how to perform authentication against a document database using MongoDB.

Chapter 6, LDAP Directory Services, will review the Lightweight Directory Access Protocol (LDAP) and learn how it can be integrated into a Spring-Security-enabled application to provide authentication, authorization, and user information services to interested constituents.

Chapter 7, Remember-me Services, demonstrates the use of the remember-me feature in Spring Security and how to configure it. We also explore additional considerations to bear in mind when using it. We’ll add the ability for an application to remember a user even after their session has expired and the browser is closed.

Chapter 8, Client Certificate Authentication with TLS, demonstrates that, although username and password authentication is extremely common, as we discussed in Chapter 1, Anatomy of an Unsafe Application, and in Chapter 2, Getting Started with Spring Security, forms of authentication exist that allow users to present different types of credentials. Spring Security caters to these requirements as well. In this chapter, we’ll move beyond form-based authentication to explore authentication using trusted client-side certificates.

Chapter 9, Opening up to OAuth 2, explains that OAuth 2 is a very popular form of trusted identity management that allows users to manage their identity through a single trusted provider. This convenient feature provides users with the security of storing their password and personal information with the trusted OAuth 2 provider, optionally disclosing personal information upon request. Additionally, the OAuth-2-enabled website offers the confidence that the users providing OAuth 2 credentials are who they say they are.

Chapter 10, SAML 2 Support, will deep dive into the world of Security Assertion Markup Language (SAML 2.0) support and how it can be seamlessly integrated into their Spring Security applications. SAML 2.0 is an XML-based standard for exchanging authentication and authorization data between identity providers (IdPs) and service providers (SPs).

Chapter 11, Fine-Grained Access Control, will first examine two ways to implement fine-grained authorization—authorization that may affect portions of a page of the application. Next, we will look at Spring Security’s approach to securing the business tier through method annotation and the use of interface-based proxies to accomplish Aspect-Oriented Programming (AOP). Then, we will review an interesting capability of annotation-based security that allows for role-based filtering on collections of data. Last, we will look at how class-based proxies differ from interface-based proxies.

Chapter 12, Access Control Lists, will address the complex topic of Access Control Lists (ACLs), which can provide a rich model of domain object instance-level authorization. Spring Security ships with a robust, but complicated, ACL module that can serve the needs of small- to medium-sized implementations reasonably well.

Chapter 13, Custom Authorization, will include some custom implementations for Spring Security’s key authorization APIs. Once we have done this, we will use the understanding of the custom implementations to understand how Spring Security’s authorization architecture works.

Chapter 14, Session Management, discusses how Spring Security manages and secures user sessions. The chapter starts by explaining session fixation attacks and how Spring Security defends against them. It then discusses how you can manage logged-in users and restrict the number of concurrent sessions a single user has. Finally, we describe how Spring Security associates a user with HttpSession and how to customize this behavior.

Chapter 15, Additional Spring Security Features, covers other Spring Security features, including common security vulnerabilities such as cross-site scripting (XSS), cross-site request forgery (CSRF), synchronizer tokens, and clickjacking, and how to protect against them.

Chapter 16, Migration to Spring Security 6, provides a migration path from Spring Security 5, including notable configuration changes, class and package migrations, and important new features, including Java 17 support and new authentication mechanisms with OAuth 2.1.

It also highlights the new features that can be found in Spring Security 6.1 and provides references to examples of the features in the book.

Chapter 17, Microservice Security with OAuth 2 and JSON Web Tokens, looks at microservices-based architectures and how OAuth 2 with JSON Web Tokens (JWT) plays a role in securing microservices in a Spring-based application.

Chapter 18, Single Sign-On with the Central Authentication Service, shows how integrating with a Central Authentication Service (CAS) can provide single sign-on and single logout support to your Spring-Security-enabled applications.

Chapter 19, Build GraalVM Native Images, looks at Spring Security 6 support for building native images using GraalVM. This can be a great way to improve the performance and security of your Spring Security applications.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY