SystemsAuthentication flow

Authentication overview

How Ziteox sites share one Account sign-in without sharing session cookies.

Authentication overview

Ziteox uses one central sign-in for every first-party site and tool. People sign in at Ziteox Account (auth.ziteox.com). Admin (admin.ziteox.com), Client (client.ziteox.com), and any future Ziteox site hand the user to Account, then receive a short-lived one-time code and set their own session cookie on their own host.

Sessions are never shared across domains. Each site keeps a host-only cookie; Account only brokers the handoff.

Why

  • One place to log in, manage two-step, and see connected apps
  • No parent-domain or cross-subdomain SSO cookie
  • Each product can enforce its own rules (staff-only, invite-only, two-step freshness)

Pieces

PieceRole
Ziteox Account (ziteox-auth)Cloudflare Worker app at auth.ziteox.com — login, MFA, account picker / Continue, issues handoff codes, token exchange
@ziteox/authShared package — site origins, safe return-to, handoff registry/params/codes/store, freshness helpers
Site routesEach site implements /auth/start, /auth/handoff, /auth/signout, plus middleware that sends unsigned-in users toward sign-in
core.appsSite registration — allowed origins, exact callback URLs, staff / two-step policy
core.app_connectionsPer-user “Connected apps” — first connected and last used, written on successful handoff

Key ideas

IdeaIn practice
Host-only sessionAdmin uses sb-zx-admin-auth-token; Client uses sb-zx-client-auth-token. No domain attribute — cookie stays on that host.
One-time handoff codeAfter login, Account issues a random code (stored only as a hash, ~60s, single use, bound to PKCE + client + redirect). The site exchanges it server-to-server for tokens.
AdminStaff-only; two-step required; second-factor freshness re-checked every 12 hours (middleware sends stale sessions back through /auth/start).
ClientInvite-only (public signup redirects to Account with an invite notice); two-step optional unless the user already enrolled factors.

How the parts connect

flowchart LR
  Browser --> Site
  Site -->|"/auth/start"| Account["Ziteox Account\nauth.ziteox.com"]
  Account -->|"login / MFA / Continue"| Account
  Account -->|"one-time code"| Site
  Site -->|"POST /api/handoff/token"| Account
  Account --> Supabase[(Supabase Auth)]
  Site -->|"host-only session cookie"| Browser
  Account -.->|"core.apps / app_connections"| DB[(core schema)]