
WisprX Auth & RBAC
sub: user IDtenantId: associated tenant/company (nullable for platform-level users)role: role type (ex: SUPER_ADMIN, TENANT_ADMIN, USER)scope: either system (WisprX Admin Panel) or tenant (Client Company Panel)@nestjs/passport with JwtStrategy to parse the token from headers. - Optional refresh token support may be added later via a secure dual-token flow.WisprX has two levels of role hierarchy, each with its own permissions:
SUPER_ADMIN: Full access to manage tenants, plans, billing, logs, etc. - ADMIN: Operational WisprX team member (support, onboarding, monitoring) - USER: Internal users with restricted read-only or support roles.ADMIN: Manages users, messages, contacts, automations, and settings for their company. - USER: Regular operator (agents, support reps, sales reps). - GUEST: Optional read-only or restricted permission (e.g., temporary access).
The token’s scope must match the requested route context.JwtAuthGuard: ensures user is authenticated.ScopeGuard: ensures scope matches (system or tenant).RolesGuard: ensures user has the right role.TenantGuard: ensures user is allowed to access that tenant’s data.@Roles('TENANT_ADMIN'), @Scopes('system'), @CurrentUser() etc.tenant must include and validate tenantId. - All database operations must be scoped using:
where tenant_id = :tenantId clauses or Prisma filters./system/users, /system/tenants, /system/billing, etc. - Tenant panel routes: /crm/contacts, /inbox, /automations, etc. - Scope must be strictly enforced per route group.sessions table with:
ip, user_agent, logged_at, revoked (bool)