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
| Piece | Role |
|---|---|
Ziteox Account (ziteox-auth) | Cloudflare Worker app at auth.ziteox.com — login, MFA, account picker / Continue, issues handoff codes, token exchange |
@ziteox/auth | Shared package — site origins, safe return-to, handoff registry/params/codes/store, freshness helpers |
| Site routes | Each site implements /auth/start, /auth/handoff, /auth/signout, plus middleware that sends unsigned-in users toward sign-in |
core.apps | Site registration — allowed origins, exact callback URLs, staff / two-step policy |
core.app_connections | Per-user “Connected apps” — first connected and last used, written on successful handoff |
Key ideas
| Idea | In practice |
|---|---|
| Host-only session | Admin uses sb-zx-admin-auth-token; Client uses sb-zx-client-auth-token. No domain attribute — cookie stays on that host. |
| One-time handoff code | After 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. |
| Admin | Staff-only; two-step required; second-factor freshness re-checked every 12 hours (middleware sends stale sessions back through /auth/start). |
| Client | Invite-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)]Where to read next
- Sign-in handoff flow — step-by-step browser → site → Account → Supabase
- Site registration and secrets —
core.apps, callbacks, site secrets - Bots and connected apps — MCP OAuth Connect, device linking, and Connected apps
- Add a new site or app — checklist to wire a new product
- Security and local development — local origins, gates, and safe defaults