liveBook · Manning

Chapter 4: Managing passwords

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

The introduction connects the previous chapter’s user management to passwords as an essential part of authentication, then previews the chapter’s topics.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction connects the previous chapter’s user management to passwords as an essential part of authentication, then previews the chapter’s topics.

Key terms: passwords, authentication flow

4.1 Using password encoders

This section introduces why passwords are transformed and where Spring Security’s PasswordEncoder fits in authentication.

Key terms: plain text, transformation, PasswordEncoder, authentication process

4.1.1 The PasswordEncoder contract

Defines how Spring Security’s PasswordEncoder encodes passwords and checks them during authentication.

Key terms: PasswordEncoder, encode(), matches(), raw password, encoded password, upgradeEncoding()

4.1.2 Implementing your PasswordEncoder

This section explains how to implement PasswordEncoder so encoded passwords can be verified, using cleartext and SHA-512 examples.

Key terms: PasswordEncoder, encode(), matches(), plain text, NoOpPasswordEncoder, equals(), SHA-512, hash, raw password

4.1.3 Choosing from the provided PasswordEncoder implementations

This section compares Spring Security’s provided password encoders and explains how to configure the PBKDF2 and bcrypt options.

Key terms: PasswordEncoder, NoOpPasswordEncoder, StandardPasswordEncoder, Pbkdf2PasswordEncoder, BCryptPasswordEncoder, SCryptPasswordEncoder, PBKDF2, HMAC, iterations, hash width

4.1.4 Multiple encoding strategies with DelegatingPasswordEncoder

Explains why an application may need multiple password encoders, how DelegatingPasswordEncoder selects among them, and how encoding, encryption, and hashing differ.

Key terms: DelegatingPasswordEncoder, hashes, PasswordEncoder, prefix, map of encoders, default encoder, encoding, encryption, decryption, symmetric key

4.2 Taking advantage of the Spring Security Crypto module

The section introduces the Spring Security Crypto module, why it can simplify project dependencies, and the basic roles of its key generators and encryptors.

Key terms: Spring Security Crypto module, SSCM, password encoders, Key generators, Encryptors

4.2.1 Using key generators

This section explains Spring Security’s string and byte key generators, including key length and whether repeated calls produce new or shared values.

Key terms: KeyGenerators, StringKeyGenerator, BytesKeyGenerator, generateKey(), salt, KeyGenerators.secureRandom(), KeyGenerators.shared(int length)

4.2.2 Encrypting and decrypting secrets using encryptors

This section explains how Spring Security Crypto encryptors handle strings and bytes, and how to choose among the provided implementations.

Key terms: BytesEncryptor, TextEncryptor, encryption, decryption, Encryptors.standard(), Encryptors.stronger(), Galois/Counter Mode (GCM), cipher block chaining (CBC), Encryptors.text(), Encryptors.delux()

4.3 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 3: Managing users Chapter 5: A web app’s security begins with filters →

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.