Auth0 JWT Bearer Token Authentication
All protected endpoints require a valid JWT token issued by Auth0.
Auth0 Configuration
- Tenant:
dev-4fszoklachwdh46m.us.auth0.com
- Issuer:
https://dev-4fszoklachwdh46m.us.auth0.com/
- Audience:
https://api.theholefoundation.org
- Algorithm: RS256 (RSA Signature with SHA-256)
- JWKS URI:
https://dev-4fszoklachwdh46m.us.auth0.com/.well-known/jwks.json
Getting a Token
For End Users (Web Application):
- Login: https://theholetruth.org/api/auth
- Uses Auth0 Universal Login
- Returns JWT in response after successful authentication
For M2M (Service-to-Service):
Using the Token
Include the JWT in the Authorization header of all API requests:
Implementation Guide (Backend)
Step 1: Fetch JWKS from Auth0
Step 2: Validate JWT
Step 3: Extract User ID
Step 4: Check Permissions
Token Claims
Every Auth0 JWT contains these claims:
Required Scopes by Endpoint Category
- Vector Search:
read:transparency
- Transparency:
read:transparency
- FOIA Dashboard:
read:foia, write:foia
- Chat:
chat:assistant
- LaTeX Compilation:
compile:documents
- Neon Database:
read:database (admin: admin:database)
- Integration Workflows:
execute:workflows
- S3 Storage:
read:storage, write:storage
- Vector Store:
read:vectors, write:vectors (admin: admin:vectors)
- Project API:
read:projects, write:projects
Error Responses
401 Unauthorized - Missing or invalid token:
401 Unauthorized - Expired token:
403 Forbidden - Insufficient permissions:
Security Best Practices
- Always validate the JWT signature using Auth0’s JWKS
- Verify the
iss claim matches Auth0 tenant
- Verify the
aud claim matches your API identifier
- Check the
exp claim to reject expired tokens
- Extract user ID from
sub claim for resource scoping
- Validate scopes before granting access to protected resources
- Use HTTPS only for all API communication
- Never log or expose JWT tokens in plaintext
- Implement rate limiting per
sub claim to prevent abuse
- Audit all access with Auth0 user ID for compliance
Neon + BetterAuth Integration
BetterAuth (Neon’s authentication layer) uses Auth0 as the JWT provider:
- Auth0 issues all JWT tokens
- BetterAuth validates tokens against Auth0’s JWKS
- User sessions stored in Neon PostgreSQL
- Row-Level Security (RLS) uses
auth.user_id() function
- RLS policies extract user ID from Auth0
sub claim
Example RLS Policy:
SDK Integration
All generated SDKs include Auth0 authentication helpers:
TypeScript SDK:
Python SDK:
Need Help?
- Auth0 Documentation: Contact api@theholefoundation.org
- M2M Credentials: Contact api@theholefoundation.org
- Permission Issues: Check your Auth0 user roles and scopes
- Token Expiration: Implement token refresh flow in your application