Authentication System
Overview
Cronozen uses JWT-based authentication with multi-tenant context. All services authenticate through a single SSO endpoint.Auth Flow
Key Components
| Component | File | Purpose |
|---|---|---|
resolveDefaultTenant() | src/lib/auth/resolve-default-tenant.ts | Default entry policy SSOT |
buildAuthDomainInfo() | src/lib/auth/build-auth-domain-info.ts | JWT authorizedDomains/domainRoles |
findActorFamilyIds() | src/lib/auth/actor-family.ts | Cross-actor family linking |
requireCenterScope() | src/core/tenant/center-scope.ts | Data isolation enforcement |
Tenant Resolution Priority
When a user logs in, the system determines their default tenant in this order:- ADMIN — Admin always goes to admin context
- URL tenant — If accessing via specific tenant URL
- Last tenant — User’s most recent tenant
- Single — If user has only one membership
- Email match — Match by email domain
- Picker — Show tenant picker
- Pending — Pending membership flow
- Onboarding — New user onboarding
JWT Structure
Actor Family
Actors with the same email or phone are automatically linked as a family. This enables:- Center switching without re-login
- Cross-center visibility for parents
- Unified session across services