Skip to content

making/demo-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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