Spring Boot Web application secured by Auth0
If you don't have a free Auth0 developer account, you can Sign up for one.
Once you have an account log in using Auth0 CLI.
$ auth0 login
Then, register your Spring Boot app on Auth0 using:
$ auth0 apps create \
--name "Auth0 Spring Boot Sample" \
--description "Auth0 Spring Boot Sample" \
--type regular \
--callbacks http://localhost:8080/login/oauth2/code/okta \
--logout-urls http://localhost:8080
--reveal
Configure the application. Update the src/main/resources/application.properties
file with the following content:
# trailing `/` is important for issuer URI
okta.oauth2.issuer=YOUR_AUTH0_ORG_URI
okta.oauth2.client-id=YOUR_AUTH0_CLIENT_ID
okta.oauth2.audience=YOUR_AUTH0_ORG_URI/api/v2/
Run
OKTA_OAUTH2_CLIENT_SECRET=YOUR_AUTH0_CLIENT_SECRET ./gradlew bootRun
For further reference, please consider the following sections:
- Official Gradle documentation
- Spring Boot Gradle Plugin Reference Guide
- Create an OCI image
- Spring Web
- Thymeleaf
The following guides illustrate how to use some features concretely:
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Handling Form Submission
These additional references should also help you: