Skip to main content

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 the Authorization header.

Obtaining a JWT Token

Sign in using the /api/v1/auths/signin endpoint:
Response:
string
required
User’s email address
string
required
User’s password

Using JWT Tokens

Include the token in the Authorization 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 the JWT_EXPIRES_IN configuration (default: -1 for no expiration):
  • -1: Never expires
  • 0: Expires immediately (single use)
  • Duration string: 30m, 2h, 7d, 4w (minutes, hours, days, weeks)
Token Response Fields:
string
The JWT token string
string
Always “Bearer”
integer
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:
Response:
API keys are only shown once upon creation. Store them securely. If lost, delete and create a new key.

Using API Keys

API keys use the same Authorization 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_keys permission (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:
When restrictions are enabled:
  • 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

  • Google
  • 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

  1. Redirect user to /oauth/{provider}/login
  2. User authenticates with the provider
  3. Provider redirects to callback URL with authorization code
  4. Open WebUI exchanges code for tokens
  5. User is authenticated and receives a JWT token

OAuth Claims Mapping

Customize how user data is extracted from OAuth tokens:
string
default:"email"
Claim containing the user’s email address
string
default:"name"
Claim containing the user’s display name
string
default:"picture"
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_ROLES become admins
  • Users must have a role in OAUTH_ALLOWED_ROLES to access the system
  • Users without allowed roles are denied access

Account Merging

Merge OAuth accounts with existing email accounts:
When enabled, signing in with OAuth links to existing accounts with matching email addresses.

Token Exchange (Advanced)

Exchange OAuth access tokens for Open WebUI JWT tokens:
Token exchange is disabled by default. Enable only when needed for external integrations.

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:
string
required
LDAP username (value of LDAP_ATTRIBUTE_FOR_USERNAME)
string
required
LDAP password
Response: Same format as JWT sign-in (token, user details, etc.)

LDAP Group Synchronization

Automatically sync LDAP groups to Open WebUI groups:
When enabled:
  • Groups from memberOf attribute 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

Only use trusted headers behind a properly configured reverse proxy. Never expose this to the public internet.

How It Works

  1. Reverse proxy authenticates the user
  2. Proxy forwards user identity in HTTP headers
  3. Open WebUI trusts these headers and creates/authenticates the user
  4. Groups are synced if WEBUI_AUTH_TRUSTED_GROUPS_HEADER is set

Example Configuration (Nginx)

Authentication Error Codes

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
Don’t:
  • Commit API keys or secrets to version control
  • Share API keys between users or applications
  • Use trusted header authentication without a reverse proxy
  • Disable authentication in production (WEBUI_AUTH=false)
  • Expose API keys in client-side code or URLs

Code Examples

Python

JavaScript (Node.js)

cURL

Next Steps

API Endpoints

Explore available API endpoints

User Management

Manage users and permissions