Kind: Interface
Source: atloria-monorepo/libs/database/src/lib/tenant-context.ts
Per-request tenant context, propagated via AsyncLocalStorage.
WHY: the cross-tenant fix is enforced primarily by ResourceOrgGuard at the controller edge. This context powers a defense-in-depth BACKSTOP in PrismaService (see tenant-backstop.ts) that detects (and, once enabled, can enforce) tenant scoping on database queries — catching the bug class where a service loads a row by id and forgets to check its organization.
The context is set by an HTTP middleware from the authenticated JWT. Background work (BullMQ workers, cron, seeds, the boot-time audience seed) runs with NO context — the backstop treats an absent context as "system" and does nothing, so it can never break a background query.
Properties
| Property | Type |
|---|---|
organizationId | string |
userId | string |
bypass | boolean |
Was this page helpful?