- Notifications
You must be signed in to change notification settings - Fork45
Oauth2 Stateless Authentication with Spring and JWT Token
License
tinmegali/Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This project usesSpring Security to authenticate and protect some Rest resources. It useswithAuthorizationServerConfigurerAdapter,ResourceServerConfigurerAdapter andWebSecurityConfigurerAdapter combined with@PreAuthorize to configure the security. It also uses anH2 embeded database to authenticate the users.
mvn spring-boot:run or build with your chosen IDE.You should install./JQ before running these Curl commands.curl trusted-app:secret@localhost:8080/oauth/token -d "grant_type=password&username=user&password=password" | jqTo get a refresh token
curl trusted-app:secret@localhost:8080/oauth/token -d "grant_type=access_token&access_tokem=[ACCESS_TOKEN]" | jqTo access a protected resource
curl -H "Authorization: Bearer [ACCESS_TOKEN]" localhost:8080/api/helloRegister new Accountcurl -H "Authorization: Bearer $(curl register-app:secret@localhost:8080/oauth/token -d "grant_type=client_credentials&client_id=register-app" | jq --raw-output ."access_token")" localhost:8080/api/register -H "Content-Type: application/json" -d '{"username":"new-user","password":"password","firstName":"First","lastName":"Last","email":"email@email.com"}' | jq
Curl sample commandsapi/mecurl -H "Authorization: Bearer $(curl trusted-app:secret@localhost:8080/oauth/token -d "grant_type=password&username=user&password=password" | jq --raw-output ."access_token")" localhost:8080/api/me | jq
About
Oauth2 Stateless Authentication with Spring and JWT Token
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.