brain/wiki/connections-auth/ce-authentication.md
The core (all-editions) auth layer: user identity creation, sign-in, and JWT session management. Supports email/password, federated OAuth (Google, SAML), and invitation-only sign-up. On first sign-up (no platformId) a new platform + personal project are auto-created.
user_identity): email + bcrypt password + provider record, one per email, shared across platforms. Holds tokenVersion (rotating it invalidates all JWTs), verified, provider, avatar.authenticationService: signUp, signInWithPassword, federatedAuthn (OAuth/SAML callbacks), switchPlatform.accessTokenManager: generateToken (7-day JWT), generateEngineToken/generateWorkerToken (long-lived), verifyPrincipal (checks tokenVersion + active status).PrincipalType: USER, ENGINE, WORKER, SERVICE, UNKNOWN.API_RATE_LIMIT_AUTHN_*): POST /v1/authentication/sign-up, /sign-in, /switch-platform."<firstName>'s Platform") → default PERSONAL project; sends OTP on Cloud prod, auto-verifies otherwise; fires USER_CREATED flag + SIGNED_UP telemetry.AP_ENVIRONMENT=development) auto-verify the identity.pickTelemetryPii). Sign-in telemetry covers password sign-in only, not SSO.tokenVersion on UserIdentity.Entry point: authenticationService, a log-taking factory called per request from authentication.controller.ts, registered as authenticationModule in app.ts.
packages/server/api/src/app/authentication/ — the whole server slice: module, controller (routes), service, shared guards in authentication-utils.ts, authorization.tspackages/server/api/src/app/authentication/lib/ — access-token-manager.ts (JWT generate/verify) and password-hasher.ts (bcrypt)packages/server/api/src/app/authentication/user-identity/ — user_identity entity and identity CRUD servicepackages/core/shared/src/lib/core/authentication/ — shared zod contracts: dto/ sign-in, sign-up, authentication-response, plus model/packages/web/src/features/authentication/ — SPA feature: hooks/auth-hooks.ts React Query mutations, components/ sign-in, sign-up, third-party and SAML logins, reset/verifypackages/web/src/app/routes/auth-routes.tsx — route declarations: /sign-in, /sign-up, /forget-password, /reset-password, /verify-email, /invitationPaths verified 2026-07-17.