Giter VIP home page Giter VIP logo

jaxenter-showcase's Introduction

jaxenter.com Spring example

This is the fourth step showing that adds OAuth Security.

Build and run

Build with

./gradlew build

and run with

java -jar ./build/libs/jaxenter-example-1.0.jar
java -jar ./authentication-server/build/libs/jaxenter-example-authentication-server-1.0.jar

Please be aware that both must be run from within the same directory so they can share the tokens database!

Example OAuth Server requests

The console client can request an access token like this:

curl curl:password@localhost:8081/oauth/token\?grant_type=client_credentials

The web client has to use this URL. Beware, it will redirect you to github since we don't have a real web client. The token is in the new github URL that you will be redirected to.

http://localhost:8081/oauth/authorize?client_id=web&response_type=token

Example requests

When running the following requests should give you results. Replace $token with the token you have gained!

curl -H "Authorization: Bearer $token" localhost:8080
curl -H "Authorization: Bearer $token" localhost:8080/persons
curl -H "Authorization: Bearer $token" -X POST -H "Content-Type: application/json" -d "{\"firstName\": \"John\"}" localhost:8080/persons
curl -H "Authorization: Bearer $token" localhost:8080/persons/search/findByFirstNameLike\?firstName=J%25
curl -H "Authorization: Bearer $token" -X PUT localhost:8080/persons/1 -d "{\"firstName\": \"Jane\"}" -H "Content-Type: application/json"
curl -H "Authorization: Bearer $token" -X DELETE localhost:8080/persons/1

When you use the web client URL the token includes the role and logged in user, so Mary still can't access John's record!

jaxenter-showcase's People

Contributors

frontierpsychiatrist avatar

Watchers

James Cloos avatar  avatar

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.