liveBook · Manning

Chapter 13: What are OAuth 2 and OpenID Connect?

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

The introduction explains why applications may separate authentication from their own responsibilities and let users reuse credentials across apps.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why applications may separate authentication from their own responsibilities and let users reuse credentials across apps.

Key terms: OAuth 2, authentication, credentials, authenticate, social media platforms

13.1 The big picture of OAuth 2 and OpenID Connect

This section introduces the actors in an OAuth 2 system and shows how a client obtains and uses an access token to access a resource server.

Key terms: user, client, resource server, authorization server, access token, grant types, non-opaque tokens, opaque tokens, expires

13.2 Using various token implementations

This section explains what OAuth 2 tokens do and distinguishes token types by how a resource server obtains authorization data.

Key terms: token, client, resource server, authorization, opaque token, non-opaque token, introspection call, JSON Web Token (JWT)

13.2.1 Using opaque tokens

Explains why an opaque token requires the resource server to ask the authorization server for validation and details before applying authorization rules.

Key terms: opaque token, resource server, authorization server, token introspection, authorization constraints

13.2.2 Using non-opaque tokens

This subsection explains how non-opaque tokens carry information, how a JWT is structured, and when an opaque token may be preferable.

Key terms: non-opaque tokens, JWT, header, body, signature, Base64, opaque tokens, introspection

13.3 Obtaining tokens through various grant types

Introduces grant types as ways for clients to obtain tokens and warns against two deprecated grant types.

Key terms: grant type, client, token, authorization server, implicit grant type, password grant type, deprecated

13.3.1 Getting a token using the authorization code grant type

Explains how the authorization code grant obtains an access token after user login and why exchanging a code is safer than returning a token in a browser redirect.

Key terms: authorization code grant type, client, authorization server, authorization code, access token, resource server, redirect, client credentials, implicit grant type

13.3.2 Applying PKCE protection to the authorization code grant type

This section explains how PKCE adds a verifier and challenge to the authorization code grant to protect the token exchange.

Key terms: PKCE, verifier, challenge, authorization code grant type, authorization code, hash function

13.3.3 Getting a token with the client credentials grant type

This section explains when an app uses the client credentials grant and how it obtains and uses an access token without a user.

Key terms: client credentials grant type, authorization server, access token, resource server

13.3.4 Using refresh tokens to get new access tokens

Explains why access tokens expire and how a client uses a refresh token to obtain a new access token without asking the user to log in again.

Key terms: tokens, access token, resource server, refresh token, authorization server, authorization code grant type

13.4 What OpenID Connect brings to OAuth 2

This section explains how OpenID Connect builds on OAuth 2 by narrowing its flexibility and adding conventions for scopes, identity information, and terminology.

Key terms: OpenID Connect, OIDC, OAuth 2, specification, protocol, scopes, profile, openid, ID token, grant type

13.5 The sins of OAuth 2

This section identifies common vulnerabilities in OAuth 2 applications and explains why secure implementation and configuration matter.

Key terms: cross-site request forgery (CSRF), client credentials, replaying tokens, token hijacking, refresh tokens, OAuth 2, framework, Spring Security, configurations, flow

13.6 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 12: Implementing filtering at the method level Chapter 14: Implementing an OAuth 2 authorization server →

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.