Security
7 Layers of Data Isolation
- HTTP Header Extraction — CompanyMiddleware reads
X-Company-Id - Access Guard — CompanyGuard validates user-company access
- Application Scope — CompanyScope adds
company_idto queries - Event Context — DomainEvent carries
companyId - Database CHECK —
CHECK (company_id IS NOT NULL)on 27 tables - Foreign Keys —
ON DELETE RESTRICTon 23 tables - Row-Level Security — PostgreSQL RLS policies on 8 tables
Runtime Database Security
The application uses a restricted role (app_user) with DML only — no DDL, no BYPASSRLS.
Audit Trail
Every action is logged with tenant ID, company ID, user ID, entity type, action, and timestamp.
Last updated on