Overview
Frontier API supports multiple authentication methods to suit different use cases:- Bearer Tokens (JWT) - For user-authenticated requests
- Service User Credentials - For machine-to-machine authentication
- Session Cookies - For browser-based applications
- Client Credentials - For OAuth2-style authentication
Most API endpoints require authentication. Only public endpoints like
/ListAuthStrategies and /Authenticate can be called without credentials.Bearer Token Authentication
The primary authentication method is using JWT (JSON Web Token) bearer tokens in theAuthorization header.
Getting a Token
First, authenticate using one of the supported strategies to obtain a token:Using the Token
Include the token in theAuthorization header with the Bearer prefix:
Bearer tokens are JWT tokens that include user/service user identity and optional claims like organization IDs and session IDs.
Token Claims
Frontier JWT tokens can include custom claims:Subject - The user or service user ID
Comma-separated list of organization IDs the user belongs to (if enabled)
Session ID for user sessions (if enabled)
Selected project context (set via
X-Project header)JWT ID - Unique token identifier
Expiration time (Unix timestamp)
Issued at time (Unix timestamp)
Service User Authentication
Service users are non-human accounts designed for machine-to-machine authentication. They’re ideal for:- API integrations
- CI/CD pipelines
- Automated scripts
- Backend services
Creating a Service User
Creating Service User Credentials
Service users authenticate using key pairs. Create credentials (secret key) for the service user:Authenticating with Service User
Use the client credentials grant type:JWT Assertion (JWK)
For enhanced security, service users can use JWT assertions with JSON Web Keys:Session-Based Authentication
For browser-based applications, Frontier supports session cookies.Starting Authentication Flow
Initiate authentication with a supported strategy:Handling Callback
After successful authentication, handle the callback:Set-Cookie header with a secure session cookie (sid).
Using Session Cookie
Browsers automatically send the session cookie with subsequent requests:Logging Out
Invalidate the session:Authentication Headers
Frontier recognizes multiple authentication headers:Bearer token or Basic authentication credentialsFormat:
Bearer <jwt_token>- For JWT tokensBasic <base64_credentials>- For service user credentials
Alternative header for passing JWT tokens
Session cookie (
sid) for browser-based authenticationOptional project context to include in the access token claims
Optional request identifier for tracing
Authentication Strategies
Frontier supports multiple authentication strategies for user login:Listing Available Strategies
Supported Strategies
OAuth2 Providers
OAuth2 Providers
- Google (
google) - Sign in with Google - GitHub (
github) - Sign in with GitHub - Other OIDC providers can be configured
Email-Based
Email-Based
- Mail Link (
maillink) - Magic link sent to email - Mail OTP (
mailotp) - One-time password sent to email
Passwordless
Passwordless
- Passkey (
passkey) - WebAuthn/FIDO2 authentication
Public Key Discovery
Frontier exposes its public keys for JWT verification via the JWKS endpoint:Security Best Practices
Token Security
- Store tokens securely - Never commit tokens to version control
- Use environment variables - Store credentials in env vars, not code
- Rotate credentials regularly - Create new service user keys periodically
- Use short-lived tokens - JWT tokens have expiration times
- Implement token refresh - Obtain new tokens before expiration
Service User Management
- Principle of least privilege - Grant minimal required permissions
- One service user per integration - Don’t share credentials across services
- Monitor usage - Track API calls made by service users
- Delete unused credentials - Remove old or compromised keys
HTTPS Requirements
- Always use HTTPS - Never send credentials over unencrypted connections
- Verify SSL certificates - Ensure valid certificates in production
- Use secure session cookies - Enable
SecureandHttpOnlyflags
Session Configuration
For session-based auth, configure these settings:Both
hash_secret_key and block_secret_key must be exactly 32 characters long.Troubleshooting
Common Authentication Errors
401 Unauthenticated
401 Unauthenticated
Error:
{"code": "unauthenticated", "message": "not authenticated"}Causes:- Missing
Authorizationheader - Invalid or expired token
- Malformed bearer token format
- Verify the token is included in the request
- Check token expiration time (
expclaim) - Ensure proper
Bearerprefix - Request a new token if expired
403 Permission Denied
403 Permission Denied
Error:
{"code": "permission_denied", "message": "not authorized"}Causes:- Insufficient permissions for the operation
- Organization or project access denied
- Disabled user or service user
- Verify user/service user has required roles
- Check resource ownership and permissions
- Ensure user/service user is enabled
404 User Not Found
404 User Not Found
Error:
{"code": "not_found", "message": "user doesn't exist"}Causes:- Invalid user ID in token claims
- Deleted user account
- Service user not found
- Verify the user/service user still exists
- Check for typos in client credentials
- Request a fresh token after user creation
Service User Authentication Fails
Service User Authentication Fails
Causes:
- Incorrect client ID or secret
- Deleted or expired credentials
- Service user disabled
- Double-check client_id and client_secret
- Verify credentials haven’t been deleted
- Ensure service user state is “enabled”
- Create new credentials if compromised
Testing Authentication
Verify your authentication setup:Next Steps
API Overview
Learn about API structure and response formats
API Endpoints
Explore available API endpoints
Service Users
Deep dive into service user management
Permissions
Understand Frontier’s permission system