Oauth2 In Spring Boot Applications

The New OAuth 2.0 Stack in Spring Security 5

Last updated 2022-01-10 | 4.7

- OAuth 2.0
- OAuth 2 Authorization Flows
- The New OAuth 2.0 stack in Spring Security 5

What you'll learn

OAuth 2.0
OAuth 2 Authorization Flows
The New OAuth 2.0 stack in Spring Security 5
Use OAuth 2.0 in Spring Boot Applications
Configure OAuth 2.0 Resource Server
Keycloak Identity and Access Management Solution
Resource Servers behind API Gateway
Register Resource Servers with Eureka Service Registry

* Requirements

* Knowledge of Java
* Knowledge of Spring Boot
* Knowledge of Spring MVC

Description

This video course is for beginner Java developers who are interested in learning how to secure OAuth 2.0 Resources in Spring Security 5.

The course covers only the new OAuth 2.0 stack in Spring Security 5.

You will learn how to: 

  • Perform each OAuth 2 authorization flow,

    • Authorization Code,

    • PKCE-enhanced authorization code,

    • Client credentials,

    • Password credentials.

  • Startup and configure the Keycloak server,

  • Configure OAuth 2 Resource Server,

  • Startup multiple Resource Servers on random port numbers,

  • Configure Spring Cloud API Gateway,

  • Configure and use Eureka Registry and Discovery Service,

  • Build a simple Spring MVC Web Application that fetches data from a protected Resource Server running behind Spring Cloud API Gateway.

  • Implement a simple JavaScript application that uses PKCE-Enhanced authorization code to acquire JWT access tokens and communicate with protected Resource Server,

  • Learn how to refresh an expired JWT Access token,

  • Learn to implement Scope-base access control,

  • Learn how to implement Role-based access control,

  • OAuth social login with Facebook, Google, and Okta accounts,

  • Implement Keycloak Remote User Authentication(User Storage SPI)

This is a step-by-step video course that explains how to use OAuth 2 from the very beginning. If you do not have experience with OAuth and would like to learn how to use it in Spring Boot Web Applications, then this video course is for you.

Who this course is for:

  • Beginner Java developer interested to learn OAuth 2.0

Course content

16 sections • 168 lectures

Source Code Preview 00:30

Presentation files Preview 00:11

Introduction Preview 04:24

Introduction to OAuth 2 Preview 07:19

OAuth 2.0 Roles Preview 03:16

Current State of OAuth 2.0 in Spring Security 5 Preview 04:18

OAuth 2.0 Client Types Preview 05:00

OAuth Access Token Preview 07:45

OAuth2 and OpenID Connect (OIDC) Preview 03:39

Introduction Preview 04:26

Authorization Code. Introduction. Preview 09:45

Authorization Code Demo. Initial Request. Preview 07:36

Authorization Code Demo. Exchange code for Access token. Preview 04:21

PKCE-enhanced Authorization Code Preview 05:37

Generating PKCE Code Verifier Preview 01:13

Generating PKCE Code Challenge Preview 01:29

PKCE Demo. Requesting Authorization Code Preview 07:20

PKCE Demo. Exchanging Code for Access Token Preview 04:43

Client Credentials Preview 01:41

Client Credentials Grant Type Demo Preview 02:37

The Password Credentials Flow Preview 02:13

The Password Credentials Flow: Demo Preview 03:01

Introduction Preview 05:04

Requesting Refresh Token that never expires Preview 02:25

Refreshing Access Token. Demonstration. Preview 03:13

Introduction Preview 04:07

Starting up Standalone Authorization Server Keycloak Preview 02:02

Starting and Stopping Keycloak Server Preview 03:40

Creating an Initial Admin User Preview 01:20

Creating a new Realm Preview 03:03

Creating a new user Preview 02:55

Creating a new OAuth client application Preview 04:52

Configuring Client Application Secrets Preview 01:05

Requesting Access Token and Refresh Token Preview 03:55

Enable/Disable OAuth 2.0 Authorization Flow Preview 02:15

OAuth 2.0 Client Scopes Preview 04:54

Introduction Preview 03:00

Creating a new project Preview 04:04

Import project into Spring Tool Suite IDE Preview 00:56

Starting Resource Server on different port number Preview 01:35

Creating a Rest Controller Class Preview 04:49

Access Token Validation URIs Preview 02:57

Accessing endpoints with an Access Token Preview 03:52

Accessing Principal and JWT Claims Preview 04:16

Demo - Accessing JWT Claims Preview 03:37

Introduction Preview 09:14

Create WebSecurityConfigurerAdapter and enable Web Security Preview 01:57

Override the default HttpSecurity configuration Preview 02:45

Configure Scope-based access control Preview 02:23

Demo - without using proper Scope Preview 03:13

Demo - using proper Scope Preview 01:05

Creating OAuth 2 Scope in Keycloak Preview 00:14

Introduction Preview 05:34

Source code Preview 00:03

Creating User Role Preview 01:14

Securing Endpoints to a Specific Role Preview 02:21

Creating Role Converter class Preview 02:08

Decoding JWT to find user roles Preview 02:11

Converting Roles into GrantedAuthority objects Preview 01:31

Register JwtAuthenticationConverter with HttpSecurity Preview 01:07

Trying how it works Preview 03:39

Introduction Preview 04:55

Source code Preview 00:03

Enable Method Level Security Preview 02:19

@Secured annotation example Preview 05:54

@PreAuthorized annotation Preview 03:59

Reading UserId from JWT Access Token Preview 05:38

Trying how the @PreAuthorized annotation works Preview 03:00

Creating getUser() to be used with @PostAuthorize Preview 03:30

@PostAuthorized annotation Preview 03:08

Trying how to the @PostAuthorized annotation works Preview 04:06

Introduction Preview 06:01

Creating API Gateway Project Preview 04:17

Import API Gateway to Spring Tool Suite Preview 00:36

Configuring API Gateway Routes Preview 06:26

Trying how it works Preview 03:45

Albums & Photos Resource Servers Preview 03:44

Routing to multiple Resource Servers Preview 03:04

Trying how it works Preview 04:09

Introduction Preview 04:39

Creating Eureka Discovery Service Project Preview 03:23

Configuring Eureka project Preview 03:49

Eureka Client Dependency Preview 04:12

@EnableDiscoveryClient and configuration properties Preview 02:45

Trying how it works Preview 00:50

Exercise Preview 01:09

Source Code Preview 00:12

Solution overview Preview 04:46

Load Balancing - Introduction Preview 02:07

Starting Resource Servers on Random IP Address Preview 04:12

Eureka and Resource Server Instance Id Preview 07:00

Configuring API Gateway as Eureka Client Preview 04:37

Configure API Gateway Routes Preview 03:24

Return the running port number Preview 02:16

Trying how it works Preview 03:46

OAuth 2.0 in MVC Web App - Introduction Preview 01:42

Source code Preview 00:05

Creating a new Spring Boot Project Preview 02:28

Creating Controller class Preview 04:12

Returning list of albums Preview 04:54

Displaying Albums in HTML Page Preview 04:21

Adding OAuth2 Client Dependency Preview 01:19

Configuring OAuth2 Client properties Preview 05:30

Configuring OAuth2 Provider properties Preview 02:39

Reading ID Token Preview 06:25

Reading JWT Access Token Preview 06:11

HTTP Request to an Internal Resource Server Preview 07:38

Trying how it works Preview 02:08

A different approach to adding access token Preview 01:27

Adding WebClient Dependency Preview 01:15

Creating a WebClient Bean Preview 04:52

Using WebClient in a Controller class Preview 02:40

Trying how it works Preview 01:41

Introduction Preview 01:54

Source code Preview 00:00

Creating a new project Preview 02:15

Protected Resource Controller class Preview 04:03

Protected Resource HTML Page Preview 03:04

Creating public page Preview 03:09

Configure HTTP Security Preview 03:04

OAuth 2 Client and Provider configurations Preview 04:53

Facebook: Client Id and Client Secret Preview 02:06

Trying how Facebook login works Preview 01:30

Google Client Id and Client Secret Preview 07:44

Trying how Google sign-in works Preview 01:05

Register a new Okta app Preview 03:49

Configure Okta properties Preview 03:40

Trying how sign-in with Okta works Preview 00:59

Configure logout functionality Preview 03:43

Configure the Logout link Preview 01:12

Trying how logout link works Preview 02:44

OpenID Connect End Session Endpoint Preview 03:51

Implementing OidcClientInitiatedLogoutSuccessHandler Preview 02:55

Trying how Logout from Okta works Preview 01:07

Introduction Preview 02:08

Creating a new Public client in Keycloak Preview 05:32

Creating a new Spring Boot client application Preview 01:25

Creating Index.html Preview 01:45

Import jQuery Preview 01:08

Generating Random State value Preview 04:11

Generating Code Verifier value Preview 02:28

Generating Code Challenge value Preview 03:26

Requesting PKCE-Enhanced Authorization Code Preview 05:10

Creating Auth Code Reader HTML Page Preview 00:59

Reading authorization code from the Redirect URI Preview 03:42

Validating "state" request parameter Preview 02:16

Exchange Code for Access Token Preview 05:45

Finding Refresh Token and ID Token Preview 02:10

Sending Request to Resource Server Preview 05:21

Configure CORS Access on API Gateway Preview 04:53

Configure CORS in Resource Server Preview 10:04

Introduction Preview 04:04

Creating a new project Preview 03:09

Creating RemoteUserStorageProvider class Preview 04:46

Creating RemoteUserStorageProviderFactory class Preview 04:03

Adding Keycloak Core Dependency Preview 01:25

Solution overview Preview 03:27

Remote Users Webservice Overview Preview 09:15

RESTEasy HTTP Client Dependency Preview 01:43

Implementing Users Api Service Preview 05:54

Creating User Class Preview 03:05

Adding the verifyUserPassword to UsersApiService Preview 03:56

Building RESTEasy HTTP Client Preview 04:45

Implementing getUserByUsername() method Preview 05:38

Verifying User Password Preview 03:47

Packaging UserStorageProvider Preview 04:16

Deploying User Storage SPI Preview 08:44

Trying how it works Preview 04:41