liveBook · Manning

Chapter 16: Implementing an OAuth 2 client

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

The introduction explains why a backend application may act as an OAuth 2 client when communicating with another backend application.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why a backend application may act as an OAuth 2 client when communicating with another backend application.

Key terms: OAuth 2 client, client credentials grant type, HTTP Basic, API Key

16.1 Implementing OAuth 2 login

This section introduces OAuth 2 login for Spring web apps and identifies when Spring Boot makes its configuration straightforward.

Key terms: Spring Boot, OAuth 2 login, authorization server, OAuth 2, OpenID Connect

16.1.1 Implementing authentication with a common provider

This section shows how to enable OAuth 2 login with Google and use Spring Security’s preset provider details to keep the configuration small.

Key terms: OAuth 2 client dependency, OAuth 2 login, authorization code grant type, well-known providers, CommonOAuth2Provider, client ID, client secret, Google Developer Console

16.1.2 Giving the user more possibilities

This section explains why an app might offer multiple OAuth 2 login providers and how adding GitHub alongside Google changes the user’s login experience.

Key terms: provider, client ID, secret, application.properties, providers, log in

16.1.3 Using a custom authorization server

This section shows how to configure an OAuth 2 login with a custom authorization server and run it alongside the web app.

Key terms: common providers, authorization endpoint, token endpoint, key set endpoint, OpenID Connect, issuer URI, client registration, provider name, client ID, client secret

16.1.4 Adding flexibility to your configurations

This section explains when property-based OAuth 2 client configuration is too limited and how to supply client registrations through a custom Spring bean.

Key terms: properties file, providers, credentials, ClientRegistration, ClientRegistrationRepository, authorization server, Spring bean, in-memory

16.1.5 Managing authorization for an OAuth 2 login

Explains how an app accesses OAuth 2 login authentication details to identify users and apply authorization restrictions.

Key terms: oauth2Login(), authentication details, security context, Authentication, SecurityContextHolder.getContext().getAuthentication(), username, authorities, OAuth2AuthenticationPrincipal, pre-/post-annotations

16.2 Implementing an OAuth 2 client

This section shows how a Spring Security application obtains an access token as an OAuth 2 client using the client credentials grant type.

Key terms: client credentials grant type, client credentials, token URI, access token, oauth2Client(), HttpSecurity, ClientRegistrationRepository, client registration, scope, OAuth2AuthorizedClientManager

16.3 Summary

Concepts explained in this chapter

← Chapter 15: Implementing an OAuth 2 resource server Chapter 17: Implementing security in reactive applications →

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.