This is a simplified Spring Boot document API, for the purpose of demonstrating Fine-grained authorization (FGA) using OpenFGA, with Auth0 as the identity provider.
Prerequisites:
To download the API project, execute the following commands:
git clone https://github.com/indiepopart/spring-api-fga.git
cd spring-api-fga/final
Sign up at Auth0 and install the Auth0 CLI. Then in the command line run:
auth0 login
The command output will display a device confirmation code and open a browser session to activate the device.
Register the API within your tenant:
auth0 apis create \
--name "Spring API" \
--identifier https://document-api.okta.com
The first line in the command output will contain your Auth0 domain.
Create a file application.yml
at the root of the final
project with the following content:
okta:
oauth2:
issuer: https://<your-auth0-domain>/
audience: https://document-api.okta.com
Run the API with:
./gradlew bootRun
Create a test access token:
auth0 test token -a https://document-api.okta.com -s openid
Save the access token in an environment variable:
ACCESS_TOKEN=<access-token>
Use the access token to make a request to the API. Create document:
curl -X POST \
-H "Authorization:Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "planning.doc"}' \
http://localhost:8080/document
Please post any questions as comments on the blog post, or on the Okta Developer Forums.
Apache 2.0, see LICENSE.