Authentication and tenancy

IdentityService, AccountService, MembershipService, JwtService and CustomContextAccessorService form the shared path. MembershipDb holds platform users/roles/company registration; TenantDb holds company-scoped operational records; WarehouseDb is reporting storage. Other contexts exist in specific modules—do not freeze a universal DbContext count from conflicting source snapshots.

JwtService signs HmacSha256 tokens and encrypts organisation/company claim values with the described environment key. Verify signature/expiry before trusting claims; encryption alone is not authorization. The accessor resolves trusted Owned/Acquired tenant IDs. Decrypt/parse failure can yield zero: services must reject missing scope, not broaden queries.

Server versus frontend enforcement

Frontend RequireRoutePermit/usePermissions tests aliases and has Primary/Secondary UI bypass. Settings' PermissionAuthorizationPolicyProvider and RequirePermission* attributes invoke PermissionAuthorizationHandler → MembershipService.UserHasPermissionAsync against role-permission rows. The shared handler has no documented universal PrimaryAdminHasFullAccess shortcut; local services can check flags separately.

The older Identity source describes incomplete service-level enforcement; Settings describes a stronger attribute family. These are source/version differences, not proof every endpoint is protected. Inventory the actual deployed controller, handler, service and record query for each sensitive action.

Session security

Frontend auth state persists tokens/roles/permissions; changeOrganization replaces session data. Verify cache clearing, old-company data disposal, refresh/revocation and membership-removal effects. Key rotation affects token validity and must be coordinated, not used as casual login repair. Keep secrets, tokens and detailed recovery operations out of employee-facing guidance.

Additional reconciliation source: Settings & roles — technical / engineering documentation

Source scope

Identity, tenancy & authorization — business view · Identity, tenancy & authorization — technical view · Identity & access — configuration · Identity, tenancy & authorization — API reference · Identity & access — user journeys · Identity & access — runbook

July Identity evidence conflicts with the more detailed Settings source on permission counts, universal owner bypass and server enforcement. Preserve the distinction: frontend owner bypass is observed in source; the shared server handler checks explicit permission rows without a universal PrimaryAdminHasFullAccess shortcut. Exact deployed guards, catalog counts, revocation/refresh, 2FA policy and SSO setup need validation.