Skip to content

making/demo-jwt

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Demo using JWT in Spring Security

This app demonstrates standalone JWT authorization in Spring Security using OAuth 2.0 Resource Server feature.

Actually it mimics OAuth2's Resource Owner Password Credentials flow.

ACCESS_TOKEN=$(curl -s localhost:8080/oauth/token -d grant_type=password -d username=demo -d password=demo | jq -r .access_token)

TODO_ID=$(curl -s localhost:8080/todos -H "Authorization: Bearer ${ACCESS_TOKEN}" -H "Content-Type: application/json" -d '{"todoTitle": "Demo"}' | jq -r .todoId)
curl -s localhost:8080/todos -H "Authorization: Bearer ${ACCESS_TOKEN}"
curl -s localhost:8080/todos/${TODO_ID} -H "Authorization: Bearer ${ACCESS_TOKEN}"
curl -s -X PUT localhost:8080/todos/${TODO_ID} -H "Authorization: Bearer ${ACCESS_TOKEN}" -H "Content-Type: application/json" -d '{"finished": "true"}'
curl -s -X DELETE localhost:8080/todos/${TODO_ID} -H "Authorization: Bearer ${ACCESS_TOKEN}"
curl -s localhost:8080/todos -H "Authorization: Bearer ${ACCESS_TOKEN}"

Releases

No releases published

Packages

No packages published

Languages