Skip to content

maddingo/oauth2-tutorial

Repository files navigation

Build status

OAuth2 with OIDC playground

This project runs 3 servers:

  • Authorization Server (Documentation)
  • Resource Server
  • Client Application

Authorization Code Flow with PKCE

sequenceDiagram
    autonumber
    actor user
    participant client-app
    participant authorization-server
    participant resource-server

    rect rgb(135, 150, 90)
    Note right of user: Getting the Access Token
    user ->> client-app: Click login link
    client-app ->> client-app: create code_verifier
    client-app ->> authorization-server: redirect to /authorize endpoint
    authorization-server ->> user: redirect to user login
    user ->> authorization-server: login and consent
    authorization-server ->> client-app: send authorization code to callback URL
    client-app ->> authorization-server: authorization code + code verifier to /token endpoint
    authorization-server ->> authorization-server: validate code verifier and challenge
    authorization-server ->> client-app: send id token + access token
    end
    rect rgb(55, 155, 0)
    Note right of client-app: Requesting Data
    client-app ->> resource-server: request data with access token
    resource-server ->> client-app: response with data
    end
Loading

Client Credential Flow

sequenceDiagram
    autonumber
    participant client-app
    participant authorization-server
    participant resource-server

    rect rgb(135, 150, 90)
    Note right of client-app: Getting the Access Token
    client-app ->> authorization-server: authenticate with client-id + client-secret to /token endpoint
    authorization-server ->> authorization-server: validate client-id + client-secret
    authorization-server ->> client-app: send access token
    end
    rect rgb(55, 155, 0)
    Note right of client-app: Requesting Data
    client-app ->> resource-server: request data with access token
    resource-server ->> client-app: response with data
    end
Loading

Development

Running the Resource Server and the Client Application requires a running Authorization Server.

Run the Script start-apps.sh to start all 3 servers.

Build with local Container Registry

docker run -d -p 5000:5000 --restart=always --name registry registry:2
mvn clean install -Dacr.publish=false -Dartifacts.server=localhost:5000

This will tag the images with localhost:5000 as docker registry.

Spring Boot and Rest

See: https://developer.okta.com/blog/2022/06/17/simple-crud-react-and-spring-boot

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors