GithubHelp home page GithubHelp logo

springboot-oauth2's Introduction

This example is based on the following resources:

How to test:

  1. $ cd authorization-server;mvn spring-boot:run

  2. $ cd resource-server;mvn spring-boot:run

  3. Obtain token with: $ curl service-account-1:service-account-1-secret@localhost:8080/auth/oauth/token -d grant_type=client_credentials and save it in TOKEN=.......

  4. Access the resource with: $ curl -H "Authorization: Bearer $TOKEN" -v localhost:9090

  5. Update the resource with: $ curl -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -X POST -d "Bonjour" -v localhost:9090

  6. $ cd webapp-server;mvn spring-boot:run

  7. go to localhost:9999 and use the UI :).

You can load the message from backend server, then submit a new one and try to reload. All calls are using JWT, AS is called only the first time, RS checks the client has correct scopes. If token expires it automatically goes to AS to get a new one.

For generating your own key (as written in the stytex.de blog):

keytool -genkeypair -alias jwt -keyalg RSA -dname "CN=jwt, L=Lugano, S=Lugano, C=CH" -keypass mySecretKey -keystore jwt.jks -storepass mySecretKey

copy jwt.jks in authorization-server/src/main/resources/jwk.jks

Notes:

  • Resource server fetch the pubkey of the authentication server, so in production it must be over a secure channel :)
  • If the authentication server is down, and a resource server is launched, the fetch of the public key will fail (but a log message will be written), see spring-attic/spring-security-oauth#734 issue

springboot-oauth2's People

Contributors

yankedev avatar syjer avatar chennl avatar

Stargazers

Shahzada Hatim avatar

Watchers

James Cloos avatar  avatar

Forkers

rtelematica

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.