Systems

Auth

Shared identity on Supabase, delivered as Ziteox Account at auth.ziteox.com.

Auth

Purpose

Auth is the shared identity layer for Ziteox apps. It sits on Supabase Auth and is delivered as Ziteox Account at auth.ziteox.com. Apps keep their own data and permissions; Account owns sign-in, memberships, roles, and invites. Staff and clients sign in once, then hand off to the app they need.

Current state

SurfaceStatus
Ziteox Account app (ziteox-auth)In progress — built in the portal repo; production go-live still gated (awaiting Laki)
Admin portal sign-in via AccountIn progress — handoff wired in code; not live until gates clear
Client portal sign-in via AccountIn progress — same handoff pattern; client split in progress
Sign-in with Ziteox Account for client Payload CMS adminsPlanned — after Account is live and the auth security audit
Cloudflare Zero Trust / Access on adminPlanned — phase 2; parked after Account go-live

What exists in code today

  • Account app — portal app ziteox-auth, OpenNext on Cloudflare Workers. See portal: ziteox-auth/CLOUDFLARE.md, portal: ziteox-auth/wrangler.jsonc, portal: ziteox-auth/open-next.config.ts, portal: ziteox-auth/src/middleware.ts, and routes under portal: ziteox-auth/src/app.
  • Shared package — portal: packages/auth (@ziteox/auth): handoff helpers, roles, agent identity, Supabase SSR factories.
  • Admin / client handoff — after Account sign-in, apps exchange a one-time code. Admin: portal: ziteox-admin/src/app/auth/start/route.ts, portal: ziteox-admin/src/app/auth/handoff/route.ts, portal: ziteox-admin/src/lib/auth-handoff.ts. Client: portal: ziteox-client/src/app/auth/start/route.ts, portal: ziteox-client/src/app/auth/handoff/route.ts. Account token API: portal: ziteox-auth/src/app/api/handoff/token/route.ts.
  • Roles — apps admin, client, rail with ranked roles in portal: packages/auth/src/roles/registry.ts. Ceiling rule (nobody grants above their own access): portal: packages/auth/src/roles/ceiling.ts.
  • Bot / agent identity — tokens prefixed zxmcp_ (portal: packages/auth/src/identity/constants.ts, portal: packages/auth/src/identity/tokens.ts). Owner ceiling for issued permissions: portal: packages/auth/src/identity/ceiling.ts. Device authorization (RFC 8628) in Account: portal: ziteox-auth/src/app/api/device/code/route.ts, portal: ziteox-auth/src/app/api/device/token/route.ts, portal: ziteox-auth/src/app/device/. MCP bearer use on admin lives at portal: ziteox-admin/src/app/api/mcp/route.ts (and related mcp-* libs).

Live gates (awaiting Laki)

Nothing below is done in production. Each item waits for Laki (from the Live gates note):

  1. Migration 190000 (must run before admin deploy, or bot keys return 401)
  2. Migration 200000
  3. Migration 210000
  4. Hosted Supabase Auth redirect allow-list
  5. Next.js upgrade to 15.5.28+
  6. Cloudflare project, DNS, and secrets for Account
  7. All deploys

Cloudflare Access on admin is parked for phase 2.

Security order

Do this in order. None started. Full write-up: Security roadmap.

  1. Ziteox Account goes live with admin and client portals
  2. Security bot audits the auth layer (tokens, session scope, blast radius) — before or alongside Payload CMS Sign-in-with-Ziteox-Account
  3. Then Cloudflare Zero Trust access control

Interfaces

How a project uses Account today or will use it:

KindWhat
Hostauth.ziteox.com (target; Worker + DNS still gated)
Portal appziteox-auth
Package@ziteox/auth — handoff, roles, identity, redirects, Supabase helpers
HandoffApp starts at /auth/start → Account login → callback /auth/handoff → POST Account /api/handoff/token
Device flowAccount /api/device/code, /api/device/token, UI at /device
Agent tokensPrefix zxmcp_; MCP endpoint on admin /api/mcp

Env var names only (values stay out of Forge; see Account .dev.vars.example and CLOUDFLARE.md):

NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY, AUTH_APP_URL, NEXT_PUBLIC_AUTH_APP_URL, AUTH_ALLOWED_RETURN_ORIGINS, ADMIN_APP_URL, CLIENT_APP_URL, ZITEOX_AUTH_USE_ACCOUNTS, CF_ACCESS_ENABLED, ZITEOX_HANDOFF_STORE, plus site URL variants listed in portal: ziteox-auth/CLOUDFLARE.md.

Project env vars stay in the admin portal, not in Forge (Env vars boundary note).

Open questions

  • When will Laki clear the live gates (migrations, redirect allow-list, Next upgrade, Cloudflare, deploys)?
  • Exact production cutover order for admin vs client once gates clear?
  • Timing and scope of Sign-in-with-Ziteox-Account for client Payload CMS admins?
  • How far bot identity (zxmcp_, device flow, owner ceiling) should be exposed as a Forge-facing interface vs portal-only?

Also listed on Open questions.

  • Systems
  • Security roadmap
  • Core
  • Loom: Ziteox Forge — Auth system · Ziteox Forge — Auth security to-dos (2026-11-01) · Shared Auth Product - auth.ziteox.com · Ziteox Account — MOC (2026-10-29) · Ziteox Account — Client auth split · Ziteox Account — Live gates (awaiting Laki) · Ziteox Shared Platform Vision · Ziteox Forge — Env vars boundary