Infrahub supports multiple authentication methods for API access. All authenticated requests require credentials to be sent with each API call.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OpsMill/infrahub/llms.txt
Use this file to discover all available pages before exploring further.
Authentication Methods
JWT Tokens
JSON Web Tokens (JWT) are the primary authentication method for user sessions. JWTs provide short-lived access tokens and long-lived refresh tokens.Login with Username and Password
Endpoint:POST /api/auth/login
SETTINGS.security.access_token_lifetime (default: 3600 seconds / 1 hour). Refresh tokens are valid for SETTINGS.security.refresh_token_lifetime.
Using Access Tokens
Include the access token in theAuthorization header:
Refreshing Access Tokens
When an access token expires, use the refresh token to obtain a new access token. Endpoint:POST /api/auth/refresh
Logout
Invalidate the current refresh token and session. Endpoint:POST /api/auth/logout
API Keys
API keys provide long-lived authentication suitable for service accounts and automation.Creating an API Key
API keys are created through the GraphQL API:Using API Keys
Include the API key in theX-INFRAHUB-KEY header:
OAuth 2.0
Infrahub supports OAuth 2.0 for delegated authentication with external providers.Supported Providers
- Google OAuth 2.0
- Custom OAuth 2.0 providers
Authorization Flow
- Initiate Authorization
GET /api/oauth2/{provider_name}/authorize
Redirect users to this endpoint to begin the OAuth flow:
- Handle Callback
GET /api/oauth2/{provider_name}/token
After user authorization, the provider redirects to this endpoint with state and code parameters. Infrahub exchanges the code for tokens and returns:
Configuration
Configure OAuth providers in your Infrahub settings:OIDC (OpenID Connect)
Infrahub supports OIDC for standards-based authentication.Authorization Flow
- Initiate Authorization
GET /api/oidc/{provider_name}/authorize
- Handle Callback
GET /api/oidc/{provider_name}/token
Returns JWT tokens after successful authentication.
Configuration
Authentication Implementation Details
JWT Token Structure
Access tokens contain:Account Status Validation
All authentication methods validate that the account status isACTIVE. Deactivated accounts receive a 401 Unauthorized response.
See /home/daytona/workspace/source/backend/infrahub/auth.py:65 for implementation details.
Security Settings
Configure authentication behavior in your settings:Authentication Priority
When multiple authentication methods are provided, Infrahub checks them in this order:- API key (
X-INFRAHUB-KEYheader) - JWT token (
Authorization: Bearerheader) - JWT token (cookie)
- Anonymous access (if enabled for GET/OPTIONS requests)
/home/daytona/workspace/source/backend/infrahub/api/dependencies.py:92 for implementation.
Error Responses
Invalid Credentials
Expired Token
Invalid Token
Account Deactivated
Best Practices
- Use API Keys for Automation - Service accounts and CI/CD should use API keys
- Rotate Tokens Regularly - Implement token rotation for long-running applications
- Store Tokens Securely - Never commit tokens to version control
- Use HTTPS - Always use HTTPS in production to protect tokens in transit
- Implement Token Refresh - Handle token expiration gracefully in client applications
- Scope API Keys - Create separate API keys for different services or environments