Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ccasro/hub/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Hub uses Auth0 for authentication and authorization. The backend validates JWT tokens issued by Auth0 and extracts user permissions for role-based access control.The Hub platform implements OAuth 2.0 with JWT bearer tokens for stateless authentication.
Prerequisites
Before configuring authentication, you need:- An Auth0 account
- An Auth0 API configured for your application
- Auth0 Application (SPA or Regular Web App) for your frontend
Auth0 Setup
Create Auth0 API
- Log in to your Auth0 dashboard
- Navigate to Applications > APIs
- Click Create API
- Set a name (e.g., “Hub API”) and identifier (e.g.,
https://api.padelhub.com) - Keep the signing algorithm as RS256
Configure permissions
In your Auth0 API, define permissions for different user roles:
read:venues- View venue informationwrite:venues- Create and update venuesread:bookings- View own bookingswrite:bookings- Create bookingsadmin:all- Full administrative access
Create Auth0 Application
- Go to Applications > Applications
- Click Create Application
- Choose Single Page Web Applications (for React/Vue frontends)
- Configure the following:
- Allowed Callback URLs:
http://localhost:3000/callback, https://app.padelhub.com/callback - Allowed Logout URLs:
http://localhost:3000, https://app.padelhub.com - Allowed Web Origins:
http://localhost:3000, https://app.padelhub.com
- Allowed Callback URLs:
Environment Configuration
Set the following environment variables:Auth0 issuer URI for JWT validationFormat:
https://YOUR_DOMAIN.auth0.com/Example: https://padelhub.eu.auth0.com/Auth0 API audience identifierExample:
https://api.padelhub.comThis must exactly match the identifier you set when creating the Auth0 API.JWT Token Structure
The backend expects JWT tokens with the following claims:JWT Token Claims
Key Claims
- iss (Issuer): Auth0 domain, validated against
AUTH0_ISSUER - aud (Audience): API identifier, validated against
AUTH0_AUDIENCE - sub (Subject): Unique user identifier (Auth0 user ID)
- permissions: Array of user permissions for authorization
- scope: OAuth 2.0 scopes
Authorization Flow
User requests authentication
Frontend redirects user to Auth0 login page with your application’s client ID.
Backend validates token
The backend:
- Verifies the JWT signature using Auth0’s public keys
- Validates the issuer matches
AUTH0_ISSUER - Validates the audience matches
AUTH0_AUDIENCE - Checks token expiration
- Extracts permissions for authorization
Security Configuration
The application implements several security measures:CORS Configuration
Allowed origins are configured based onAPP_FRONTEND_URL:
SecurityConfig.java
HTTP Security Headers
- Content Security Policy:
default-src 'self'; frame-ancestors 'none' - HSTS: Enabled with 1-year max age and includeSubDomains
- Session Management: Stateless (no server-side sessions)
Public Endpoints
The following endpoints do not require authentication:/actuator/health- Health check/v3/api-docs/**- OpenAPI documentation (disable in production)/swagger-ui/**- Swagger UI (disable in production)
Permission-Based Authorization
Protect endpoints using Spring Security’s method security:Permissions from the JWT are prefixed with
PERM_ by the JwtAuthenticationConverter.Testing Authentication
Get a Test Token
Use Auth0’s test feature or implement a login flow in your frontend:cURL Example
Make Authenticated Request
Authenticated API Call
Expected Responses
Success (200 OK):Troubleshooting
Token Validation Failures
Invalid issuer
Invalid issuer
Error:
The iss claim is not validSolution: Verify AUTH0_ISSUER matches your Auth0 domain exactly, including the trailing slash.Invalid audience
Invalid audience
Error:
The aud claim is not validSolution: Ensure AUTH0_AUDIENCE matches the API identifier in Auth0 exactly.Token expired
Token expired
Error:
Jwt expired at...Solution: Tokens have a limited lifetime (typically 24 hours). Request a new token or implement token refresh.Missing permissions
Missing permissions
Error:
Access Denied (403)Solution: Check that the user has the required permissions in Auth0. Permissions must be added to the JWT token.Debugging Tips
-
Enable debug logging:
- Decode JWT tokens: Use jwt.io to inspect token contents
- Check Auth0 logs: Review authentication logs in the Auth0 dashboard
-
Verify public keys: Ensure the backend can access
https://YOUR_DOMAIN.auth0.com/.well-known/jwks.json
Next Steps
Database Configuration
Set up PostgreSQL database
User Management
Manage users via API
Frontend Development
Frontend Auth0 integration
Environment Variables
Configure Auth0 environment