Skip to main content
The Bitwarden Web Vault is built with Angular using a traditional NgModule-based architecture. This document covers the application structure, routing, guards, and key architectural patterns.

Application Bootstrap

Entry Point

The application bootstraps from apps/web/src/main.ts:

App Module Structure

The OSS version (apps/web/src/app/app.module.ts):
The commercial version is located at bitwarden_license/bit-web/app.module.ts and extends the OSS module with enterprise features.

Core Module

The Core Module (apps/web/src/app/core/core.module.ts) provides foundational services:
  • Dependency Injection: Sets up all service providers
  • Client Type: Registers as ClientType.Web
  • Platform Services: Web-specific implementations (file download, platform utils, storage)
  • Authentication Services: Account, auth, SSO, and user decryption services
  • Cryptographic Services: Encryption, key management, and crypto functions
  • State Management: Observable storage services for disk and memory

Key Services

Routing Architecture

Main Routing Module

The OSS routing module (apps/web/src/app/oss-routing.module.ts) defines the primary application routes:

Lazy Loading

The web vault extensively uses Angular’s lazy loading for code splitting:
This reduces initial bundle size and improves load times.

Organization Routing

Organization Routes

From apps/web/src/app/admin-console/organizations/organization-routing.module.ts:

Organization Route Resolution

The redirect guard determines the appropriate landing page based on permissions:
This ensures users land on the first page they have permission to access.

Route Guards

Authentication Guards

From @bitwarden/angular/auth/guards:
  • authGuard: Ensures user is authenticated
  • lockGuard: Checks if vault is locked
  • unauthGuardFn: Redirects authenticated users away from auth pages
  • tdeDecryptionRequiredGuard: Handles trusted device encryption flows

Organization Permission Guards

Location: apps/web/src/app/admin-console/organizations/guards/

Organization Permissions Guard

File: org-permissions.guard.ts The primary guard for organization access control:
Usage example:

Enterprise Organization Guard

File: is-enterprise-org.guard.ts Checks if an organization is enterprise tier:

Additional Guards

  • is-paid-org.guard.ts: Checks if organization has a paid subscription
  • org-redirect.guard.ts: Handles automatic redirects to appropriate org pages

Other Guards

  • deepLinkGuard: Handles deep linking scenarios
  • premiumInterestRedirectGuard: Manages premium feature interest flows
  • setupExtensionRedirectGuard: Redirects users to extension setup when appropriate

Multi-Tenant Organization Features

The web vault is designed for enterprise multi-tenant organizations:

Permission Helpers

From @bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction:
  • canAccessOrgAdmin(org) - Can access admin console
  • canAccessVaultTab(org) - Can view organization vault
  • canAccessMembersTab(org) - Can manage members
  • canAccessGroupsTab(org) - Can manage groups
  • canAccessReportingTab(org) - Can view reports
  • canAccessSettingsTab(org) - Can modify settings

Organization Structure

Organization Policies

Organizations can enforce policies on members:

Environment Selection

The web vault supports region selection for cloud deployments: File: apps/web/src/app/components/environment-selector/environment-selector.component.ts
This allows users to switch between US and EU regions in cloud deployments.

Feature Flags

The web vault uses feature flags for gradual rollouts:

State Management

The web vault uses RxJS observables for state management:
  • Observable Storage: Disk and memory storage with reactive updates
  • Account Service: Active account state management
  • Organization Service: Organization membership and permissions
  • Sync Service: Data synchronization with server

Testing

The web vault uses Jest for unit testing:
Test files are co-located with source files using the .spec.ts extension.