Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/curityio/springboot-api-jwt-validation
Spring Boot API OAuth Integration and Validation of JWTs
https://github.com/curityio/springboot-api-jwt-validation
api claims code-example jwt-validation oauth2 scopes spring-boot zero-trust
Last synced: about 10 hours ago
JSON representation
Spring Boot API OAuth Integration and Validation of JWTs
- Host: GitHub
- URL: https://github.com/curityio/springboot-api-jwt-validation
- Owner: curityio
- License: apache-2.0
- Created: 2021-04-07T15:24:57.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-16T07:13:29.000Z (over 1 year ago)
- Last Synced: 2024-12-03T11:11:59.639Z (about 2 months ago)
- Topics: api, claims, code-example, jwt-validation, oauth2, scopes, spring-boot, zero-trust
- Language: Java
- Homepage: https://curity.io/resources/learn/spring-boot-api/
- Size: 75.2 KB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot API OAuth Integration
[![Quality](https://img.shields.io/badge/quality-experiment-red)](https://curity.io/resources/code-examples/status/)
[![Availability](https://img.shields.io/badge/availability-source-blue)](https://curity.io/resources/code-examples/status/)A basic sample to show how to use Spring Boot as an OAuth framework for managing JWT validation.\
After validating the JWT, the controller then uses scopes and claims from the API when serving data.## Run the API
First ensure that a Java Development Kit of 17 or later is installed.\
Then edit the application.yml file to point to a valid issuer URI:```yaml
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: https://idsvr.example.com/oauth/v2/oauth-anonymous
```## Run the API
Build and run the API with the following command, and the API will listen on port 8080 by default:
```bash
./gradlew bootRun
```## Call the API
The API requires a valid JWT access token, or it will return a 401 response:
```bash
curl -i http://localhost:8080/services -H "Authorization: Bearer eyJraWQiOiIxNzQwNDU5OTIxIiwieDV0..."
```The JWT access token must have a `services:read` scope or the API will return a 403 response.\
If the access token includes a claim containing `role=developer`, then the API returns additional data.## Further Information
- See the [Spring Boot API Tutorial](https://curity.io/resources/learn/spring-boot-api/) for a technical walkthrough
- Please visit [curity.io](https://curity.io/) for more information about the Curity Identity Server.