Skip to content

daggerok/spring-boot-oauth2-apps

Repository files navigation

spring-boot-oauth2-apps CI

Yet another... in progress...

     +-----+                                 +-----+                               +---------------+
     |  B  | -- (1) protected resource ----> |     | -- (4) authorization grant -> | authorization |
     |  R  | <- (2) unauthorized ----------- |  A  | <- (5) access token --------- |     server    |
 \O_ |  O  | -- (3) authorization ---------> |     |                               +---------------+
  |  |  W  |                                 |  P  |
 / \ |  S  |                                 |     |                               +---------------+
     |  E  | <- (8) protected resource ----- |  P  | -- (6) access token --------> |    resource   |
     |  R  |                                 |     | <- (7) protected resource --- |     server    |
     +-----+                                 +-----+                               +---------------+

build, run and test

  1. using java 14, build and run apps:
    brew cask reinstall adoptopenjdk14
    ./mvnw clean ; ./mvnw -pl :authorization-server,:app
    java -jar authorization-server/target/*.jar &
    java -jar app/target/*.jar &
  2. open in browser: http://127.0.0.1:8080
  3. click register
  4. you should be redirected with url: http://localhost:8081/oauth/authorize?grant_type=authorization_code&response_type=code&client_id=first-client
  5. authenticate with: enduser / enduserpassword
  6. you should be redirected on authorization page
  7. allow or deny...
  8. once allowed, click Authorize
  9. you should be redirected back to target page with authorization code present in a browser url

jib

./mvnw clean package jib:docker

step 1

__

jdk14
./mvnw -f step-1/step-1-authorization-server
java -jar ./step-1/step-1-authorization-server/target/*.jar
curl -sS first-client:noonewilleverguess@0:8081/oauth/token -d grant_type=client_credentials -d scope=any
curl -sS first-client:noonewilleverguess@0:8081/oauth/token -d grant_type=password -d scope=any -d username=enduser -d password=enduserpassword

step 0

__

jdk14
./mvnw -f step-0/step-0-authorization-server
java -jar ./step-0/step-0-authorization-server/target/*.jar
curl first-client:noonewilleverguess@localhost:8081/oauth/token -dgrant_type=client_credentials -dscope=any

resources