How octaviofarinia/auth0_spring_boot_rest_api works
Project type and purpose
• Type: Backend-only REST API (Spring Boot “Resource Server”)
• Purpose: Expose public, client-scoped and admin-scoped endpoints, validating JWTs issued by Auth0.
Core components (to represent
a. External parties
– Clients (e.g. browser or mobile app)
– Auth0 (Identity Provider issuing JWTs, exposing JWKS endpoints)
b. Spring Boot Application
– Security Layer
• OAuth2 Resource-Server filter chain
• AudienceValidator
• SecurityConfiguration (defines URL-to-scope/role rules)
– Controllers
• PublicController (no auth required)
• ClientController (requires “read:messages” scope)
• AdminController (requires “admin” role)
c. Development/Test Harness
– Maven wrapper, pom.xml, unit tests under src/test
Relationships and data flows
1. Client requests token from Auth0 (not shown as part of this service, but can be annotated).
2. Client attaches JWT in Authorization header to API request.
3. Spring Security intercepts incoming HTTP request.
– Validates signature against Auth0’s JWKS URI
– AudienceValidator checks the “aud” claim
– SecurityConfiguration enforces required scopes or roles per endpoint
4. If valid, request passes to the appropriate Controller.
5. Controller executes business logic (currently simple responses) and returns JSON to client.
Architectural patterns and design principles
• OAuth2 Resource Server pattern (externalizing auth to Auth0)
• Layered design: Security → Controllers → (Services/Repositories)
• Centralized configuration via Spring’s @Configuration classes