https://github.com/phxql/spring-boot-oauth2-jwt
Example project for OAuth2 with JWT tokens in Spring Boot
https://github.com/phxql/spring-boot-oauth2-jwt
Last synced: about 1 year ago
JSON representation
Example project for OAuth2 with JWT tokens in Spring Boot
- Host: GitHub
- URL: https://github.com/phxql/spring-boot-oauth2-jwt
- Owner: phxql
- Created: 2019-02-24T22:23:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-25T19:19:04.000Z (over 7 years ago)
- Last Synced: 2025-01-08T08:14:25.955Z (over 1 year ago)
- Language: Java
- Size: 57.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example project for OAuth2 with JWT tokens in Spring Boot
This applicaton showcases a Spring Boot Service:
* issues OAuth2 tokens, encoded in JWT format, using RSA signing
* verifies these tokens when protected endpoints are called
* returns the RSA public key to the client so that it can validate the issued tokens
* uses roles to protect endpoints, some endpoints are world-readable
* implements a custom `UserDetailsService` for managing users
* tests the whole Spring Security stuff in an integration test
## curls
### Issue a token
```
curl id:secret@localhost:8080/oauth/token -d grant_type=password -d username=user2 -d password=password2 -d scope=foo
```
Store the issued `access_token` in the variable `ACCESS_TOKEN`.
### Call the protected endpoint
```
curl localhost:8080/test/user -H "Authorization: Bearer $ACCESS_TOKEN"
```
### Download RSA public key for token verification
```
curl localhost:8080/oauth/token_key
```