Skip to main content
The Identity service provides authentication and authorization for Bitwarden Server using OAuth 2.0 and OpenID Connect protocols, built on Duende IdentityServer.

Overview

The Identity service handles:
  • User Authentication: Password-based login, SSO integration
  • OAuth 2.0 Flows: Authorization code, client credentials, resource owner password
  • OpenID Connect: Identity token issuance and validation
  • Token Management: Access tokens, refresh tokens, identity tokens
  • SSO Integration: External authentication via SSO service
  • Device Authorization: Device-specific authentication flows

Architecture

OAuth 2.0 Flows

Authorization Code Flow

Used by web and mobile clients for user authentication:
1

Authorization Request

Client redirects to /connect/authorize with client_id and redirect_uri
2

User Authentication

User authenticates with username/password or SSO
3

Authorization Code

Identity service redirects back with authorization code
4

Token Exchange

Client exchanges code for access token at /connect/token

Client Credentials Flow

Used for server-to-server authentication (Public API, SCIM):

Resource Owner Password Flow

Used by CLI and desktop clients:

Configuration

Application Settings

From src/Identity/Startup.cs:33:
Service Configuration

IdentityServer Configuration

The service uses Duende IdentityServer for OAuth/OIDC implementation:
IdentityServer is configured with signing certificates for token validation.
Certificate Configuration

Supported Scopes

The Identity service issues tokens with the following scopes:

Client Types

Bitwarden defines several OAuth clients:
Client Definitions

Authentication Schemes

From src/Identity/Startup.cs:98:

SSO Integration

The Identity service integrates with the SSO service for enterprise authentication:
SSO Configuration

Controllers

The Identity service exposes several endpoints:

SSO Controller

Handles SSO login flows:

Accounts Controller

User account operations:

IdentityServer Endpoints

Standard OAuth/OIDC endpoints:

Token Structure

Access Token Claims

Access tokens include the following claims:

Refresh Tokens

Refresh tokens are long-lived and must be stored securely by clients.
Refresh tokens enable clients to obtain new access tokens without re-authentication:
Refresh Token Flow

Two-Factor Authentication

The Identity service integrates 2FA into the authentication flow:
1

Primary Authentication

User provides username and password
2

2FA Challenge

Identity service responds with TwoFactorRequired error and available providers
3

2FA Verification

Client resubmits with 2FA code and provider
4

Token Issuance

Identity service issues tokens upon successful 2FA verification
Supported 2FA providers:
  • Authenticator apps (TOTP)
  • Email
  • Duo Security
  • YubiKey
  • FIDO2 WebAuthn

Rate Limiting

The Identity service implements rate limiting to prevent brute force attacks:
Rate Limits

Middleware Pipeline

From src/Identity/Startup.cs:170:
Request Pipeline

Deployment

Environment Variables

Docker

Self-Hosted Configuration

In self-hosted deployments, the Identity service runs at /identity path.
Nginx Configuration

Discovery Document

The Identity service exposes an OpenID Connect discovery document:
Response includes:
  • Authorization endpoint
  • Token endpoint
  • Supported grant types
  • Supported scopes
  • Signing keys (JWKS)

Background Services

From src/Identity/Startup.cs:157:
Hosted Services
The cache service synchronizes user permissions and organization data across instances.