Skip to main content
Bitwarden Server uses a rich domain model with entities representing users, organizations, vault items, and more. All entities inherit from ITableObject<T> and follow consistent patterns.

Entity Base Interfaces

ITableObject

The foundation interface for all entities:
src/Core/Entities/ITableObject.cs
All entities have:
  • Unique identifier (Guid for most entities)
  • SetNewId() method - Generates COMB GUIDs for better indexing

IRevisable

Tracks when entities were last modified:
src/Core/Entities/IRevisable.cs
Used for synchronization - clients only fetch entities modified since last sync.

IStorableSubscriber

Marks entities related to billing:
src/Core/Entities/IStorableSubscriber.cs

Core Entities

User

Represents a Bitwarden user account.
src/Core/Entities/User.cs
Key Properties:
  • Email: Unique identifier, used for login
  • MasterPassword: Server-side hash (not the client hash!)
  • Key: User’s encryption key, encrypted with master password
  • AccountRevisionDate: Updated whenever sync data changes

Organization

Represents a shared organization vault.
src/Core/AdminConsole/Entities/Organization.cs
Plan Types:

Cipher

Represents a vault item (password, note, card, or identity).
src/Core/Vault/Entities/Cipher.cs
Cipher Types:
Data Structure (encrypted JSON):

Collection

Groups ciphers within an organization.
src/Core/Entities/Collection.cs

OrganizationUser

Links users to organizations with roles.
src/Core/AdminConsole/Entities/OrganizationUser.cs
User Types:
Status Types:

Group

Groups users within an organization.
src/Core/AdminConsole/Entities/Group.cs

Policy

Enforces organization-wide rules.
src/Core/AdminConsole/Entities/Policy.cs
Policy Types:

Relationship Entities

CollectionCipher

Links ciphers to collections (many-to-many).
src/Core/Entities/CollectionCipher.cs

CollectionUser

Grants users access to collections.
src/Core/Entities/CollectionUser.cs

CollectionGroup

Grants groups access to collections.
src/Core/Entities/CollectionGroup.cs

GroupUser

Links users to groups (many-to-many).
src/Core/AdminConsole/Entities/GroupUser.cs

Entity Relationship Diagram

Supporting Entities

Device

Tracks user devices for push notifications and verification.
src/Core/Entities/Device.cs

Folder

Personal organization folders for ciphers.
src/Core/Entities/Folder.cs

Data Encryption

Encryption Patterns

User Data:
  • Encrypted with user’s encryption key
  • Key derived from master password
  • Stored as: {encType}.{base64EncodedData}
Organization Data:
  • Encrypted with organization key
  • Organization key encrypted per-user
  • Shared among all members
Encryption Types:

Database Schema

Naming Conventions

  • Tables: PascalCase (e.g., User, OrganizationUser)
  • Columns: PascalCase (e.g., CreationDate, RevisionDate)
  • Stored Procedures: [TableName]_[Operation] (e.g., User_ReadByEmail)

Common Patterns

All tables have:
  • Id: UNIQUEIDENTIFIER (GUID), primary key
  • CreationDate: DATETIME2(7), defaults to GETUTCDATE()
  • RevisionDate: DATETIME2(7), defaults to GETUTCDATE()

JSON Properties

Many entities store complex data as JSON strings:
  • User.TwoFactorProviders: Dictionary of 2FA configurations
  • Organization.TwoFactorProviders: Organization-level 2FA
  • Cipher.Data: Encrypted vault item data
  • Cipher.Attachments: Attachment metadata
  • Policy.Data: Policy-specific configuration

Example: TwoFactorProviders JSON

See Also