Authentication
Open WebUI supports multiple authentication methods to secure API access. Choose the method that best fits your use case.Authentication Methods
1. JWT Token Authentication
JSON Web Tokens (JWT) are the primary authentication method for user sessions. Tokens are obtained by signing in and included in theAuthorization header.
Obtaining a JWT Token
Sign in using the/api/v1/auths/signin endpoint:
User’s email address
User’s password
Using JWT Tokens
Include the token in theAuthorization header with the Bearer scheme:
JWT tokens are signed using the
WEBUI_SECRET_KEY environment variable with the HS256 algorithm.Token Expiration
Tokens expire based on theJWT_EXPIRES_IN configuration (default: -1 for no expiration):
-1: Never expires0: Expires immediately (single use)- Duration string:
30m,2h,7d,4w(minutes, hours, days, weeks)
The JWT token string
Always “Bearer”
Unix timestamp when the token expires (null if never expires)
Token Revocation
Tokens can be revoked by signing out:Token revocation requires Redis. Revoked tokens are stored with TTL matching the token expiration.
2. API Key Authentication
API keys provide non-expiring authentication suitable for programmatic access and integrations.Generating an API Key
Create an API key for your user account:Using API Keys
API keys use the sameAuthorization header format as JWT tokens:
API keys are prefixed with
sk- to distinguish them from JWT tokens.API Key Requirements
- API keys must be enabled globally:
ENABLE_API_KEYS=true - Users need the
features.api_keyspermission (admins have this by default) - Each user can have one active API key at a time
Retrieving Your API Key
Get your current API key:Deleting an API Key
Revoke your API key:API Key Endpoint Restrictions
Administrators can restrict API keys to specific endpoints:- JWT tokens have full access to all endpoints
- API keys can only access whitelisted endpoints
- Attempting to access a restricted endpoint returns
403 Forbidden
3. OAuth 2.0 / OpenID Connect
Open WebUI supports OAuth 2.0 and OpenID Connect for SSO with external providers.Supported Providers
- Microsoft Azure AD
- GitHub
- Generic OpenID Connect providers
- Custom OAuth providers
OAuth Configuration
Configure OAuth providers via environment variables or the admin panel:OAuth Flow
- Redirect user to
/oauth/{provider}/login - User authenticates with the provider
- Provider redirects to callback URL with authorization code
- Open WebUI exchanges code for tokens
- User is authenticated and receives a JWT token
OAuth Claims Mapping
Customize how user data is extracted from OAuth tokens:Claim containing the user’s email address
Claim containing the user’s display name
Claim containing the user’s profile image URL
Role-Based Access with OAuth
Map OAuth roles to Open WebUI roles:- Users with roles in
OAUTH_ADMIN_ROLESbecome admins - Users must have a role in
OAUTH_ALLOWED_ROLESto access the system - Users without allowed roles are denied access
Account Merging
Merge OAuth accounts with existing email accounts:Token Exchange (Advanced)
Exchange OAuth access tokens for Open WebUI JWT tokens:4. LDAP Authentication
Authenticate users against LDAP/Active Directory servers.LDAP Configuration
Configure LDAP via environment variables or admin panel:LDAP Sign-In
Authenticate with LDAP credentials:LDAP username (value of LDAP_ATTRIBUTE_FOR_USERNAME)
LDAP password
LDAP Group Synchronization
Automatically sync LDAP groups to Open WebUI groups:- Groups from
memberOfattribute are synced on each login - New groups are created if
ENABLE_LDAP_GROUP_CREATION=true - User group memberships are updated to match LDAP
5. Trusted Header Authentication
Delegate authentication to a reverse proxy or SSO gateway.Configuration
How It Works
- Reverse proxy authenticates the user
- Proxy forwards user identity in HTTP headers
- Open WebUI trusts these headers and creates/authenticates the user
- Groups are synced if
WEBUI_AUTH_TRUSTED_GROUPS_HEADERis set
Example Configuration (Nginx)
Authentication Error Codes
| Status | Error | Description |
|---|---|---|
401 | Invalid credentials | Incorrect email/password |
401 | Invalid token | JWT token is malformed or expired |
401 | Not authenticated | No authentication provided |
403 | API key not allowed | API keys disabled or user lacks permission |
403 | API key not allowed to access this endpoint | Endpoint restriction enabled |
403 | Access prohibited | User role insufficient for operation |
429 | Rate limit exceeded | Too many sign-in attempts |
Security Best Practices
Do:
- Use HTTPS in production to encrypt tokens in transit
- Store API keys securely (environment variables, secrets manager)
- Rotate API keys periodically
- Use short-lived JWT tokens for interactive sessions
- Enable Redis for token revocation
- Implement endpoint restrictions for API keys
- Use OAuth for SSO and centralized user management
Code Examples
Python
JavaScript (Node.js)
cURL
Next Steps
API Endpoints
Explore available API endpoints
User Management
Manage users and permissions