messages
resource if users have the manager access level, and a write access to that resource if they have the administrator access level.You can define allowed permissions in the Permissions view of the Auth0 Dashboard’s APIs section.read:messages
scope./src/main/resources/application.yml
file, which configures it to use the correct Auth0 domain and API Identifier for your API. If you download the code from this page it will be automatically configured. If you clone the example from GitHub, you will need to fill it in yourself.If you are using Gradle, you can add the required dependencies using the Spring Boot Gradle Plugin and the Dependency Management Plugin to resolve dependency versions:pom.xml
file:SecurityFilterChain
, and add the @Configuration
annotation.GET /api/public
: available for non-authenticated requestsGET /api/private
: available for authenticated requests containing an access token with no additional scopesGET /api/private-scoped
: available for authenticated requests containing an access token with the read:messages
scope grantedHttpSecurity
object provided in the filterChain()
method of the SecurityConfig
class. Route matchers restrict access based on the level of authorization required.GrantedAuthority
for each scope in the scope
claim of the JWT. This scope enables using the hasAuthority("SCOPE_read:messages")
method to restrict access to a valid JWT that contains the read:messages
scope.Message
as an example domain object to return during the API calls.Create a new class named APIController
to handle requests to the endpoints. The APIController
has three routes as defined in the Protect API Endpoints section. For this example, allow all origins through @CrossOrigin
annotation. Real applications should configure CORS
for their use case.To build and run the sample project, execute the bootRun
Gradle task.Linux or macOS:spring-boot:run
goal.Linux or macOS:http://localhost:3010/
. Read about how to test and use your API in the Using Your API article.messages
resource if users have the manager access level, and a write access to that resource if they have the administrator access level.You can define allowed permissions in the Permissions view of the Auth0 Dashboard’s APIs section.read:messages
scope./src/main/resources/application.yml
file, which configures it to use the correct Auth0 domain and API Identifier for your API. If you download the code from this page it will be automatically configured. If you clone the example from GitHub, you will need to fill it in yourself.pom.xml
file:SecurityFilterChain
, and add the @Configuration
annotation.GET /api/public
: available for non-authenticated requestsGET /api/private
: available for authenticated requests containing an access token with no additional scopesGET /api/private-scoped
: available for authenticated requests containing an access token with the read:messages
scope grantedHttpSecurity
object provided in the filterChain()
method of the SecurityConfig
class. Route matchers restrict access based on the level of authorization required.GrantedAuthority
for each scope in the scope
claim of the JWT. This scope enables using the hasAuthority("SCOPE_read:messages")
method to restrict access to a valid JWT that contains the read:messages
scope.Message
as an example domain object to return during the API calls.APIController
to handle requests to the endpoints. The APIController
has three routes as defined in the Protect API Endpoints section. For this example, allow all origins through @CrossOrigin
annotation. Real applications should configure CORS
for their use case.bootRun
Gradle task.Linux or macOS:spring-boot:run
goal.Linux or macOS:http://localhost:3010/
. Read about how to test and use your API in the Using Your API article.