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_uri2
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/tokenClient Credentials Flow
Used for server-to-server authentication (Public API, SCIM):Resource Owner Password Flow
Used by CLI and desktop clients:Configuration
Application Settings
Fromsrc/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
Fromsrc/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 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 providers3
2FA Verification
Client resubmits with 2FA code and provider
4
Token Issuance
Identity service issues tokens upon successful 2FA verification
- Authenticator apps (TOTP)
- Duo Security
- YubiKey
- FIDO2 WebAuthn
Rate Limiting
The Identity service implements rate limiting to prevent brute force attacks:Rate Limits
Middleware Pipeline
Fromsrc/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:- Authorization endpoint
- Token endpoint
- Supported grant types
- Supported scopes
- Signing keys (JWKS)
Background Services
Fromsrc/Identity/Startup.cs:157:
Hosted Services
Related Services
- SSO Service - Enterprise SSO authentication
- API Service - Resource server for OAuth tokens
- Admin Service - Administrative functions