How portals link
Shared Supabase, packages, Ziteox Account handoff, memberships, and cross-app tokens.
How portals link
Purpose
Admin and client portals are separate hosts and sessions, but they share one platform monorepo, one Supabase project (layered schemas), shared @ziteox/* packages, and Ziteox Account for sign-in. There is no silent cross-portal SSO (parent-domain cookie rejected).
Current state
| Link | Status |
|---|---|
Shared monorepo (ziteox-platform / portal checkout) | Live — ziteox-admin, ziteox-client, ziteox-auth, packages |
| Shared Supabase + schema routing | Live in code |
| Account handoff (PKCE one-time codes) | In progress — coded; production gated |
core.apps / memberships / invites / connections | In migrations — apply/go-live gated with Account |
| Forge Core admin token UI | Not built on the portal yet (Core API exists locally) |
Shared database
- One Supabase project for admin and client (same
NEXT_PUBLIC_SUPABASE_URLpattern in both apps’ env examples). - Layered Postgres schemas mapped in
portal: packages/supabase-routing—TABLE_SCHEMA+wrapSupabaseSchemaRouting. Layers includecore,projects,billing,infra,support,outreach,inbound,hosting,email,partner,finance,zix. - Apps re-export / wrap clients so
.from("organizations")hitscore.organizations,.from("secrets")hitsinfra.secrets, etc. Client:portal: ziteox-client/src/lib/supabase-schema-routing.ts. - Migrations: both
portal: ziteox-admin/supabase/migrations/andportal: ziteox-client/supabase/migrations/; monorepo README treats client supabase folder as the CLI sync home.
Shared packages
From portal: packages/README.md:
| Package | Role |
|---|---|
@ziteox/auth | Handoff, roles, ceiling, AAL, sites, invite verify, agent identity |
@ziteox/supabase-routing | Schema map + client wrap |
@ziteox/supabase-utils | Anon / service-role factories |
@ziteox/audit-core | Shared audit writer |
@ziteox/storage | Bunny Storage helpers |
@ziteox/dns | Cloudflare DNS helpers |
@ziteox/domain-utils | Domain normalize/validate |
@ziteox/ui comes from Forge (GitHub Packages); admin consumes it today.
Ziteox Account sign-in + handoff
Design rule (portal: docs/auth-shared-layer-plan-2026-10-29.md): sign-in on admin must not auto-sign into client (or vice versa). Each portal gets a host-only cookie after explicit handoff.
Flow (both portals):
- User hits portal
/auth/start(optionalreturn_to). - Portal stores PKCE verifier + state in a short-lived handoff cookie; redirects to Account (
getAuthAppOrigin()→ defaulthttps://auth.ziteox.com). - User signs in / picks account on Account; Account issues a one-time code (
core.auth_handoff_codes). - Portal
/auth/handoffexchanges code viaPOSTAccount/api/handoff/token(with siteclient_secret); sets portal session cookie.
Code pointers:
| Piece | Path |
|---|---|
| Admin start / handoff | portal: ziteox-admin/src/app/auth/start/route.ts, …/handoff/route.ts, …/lib/auth-handoff.ts |
| Client start / handoff | portal: ziteox-client/src/app/auth/start/route.ts, …/handoff/route.ts, …/lib/auth-handoff.ts |
| Account token API | portal: ziteox-auth/src/app/api/handoff/token/route.ts |
| Shared handoff + registry | portal: packages/auth/src/handoff/ |
| Cookie policy | portal: packages/auth/src/cookie-options.ts (host-only; no parent domain) |
| Handoff codes migration | portal: ziteox-admin/supabase/migrations/20261029210000_auth_handoff_codes.sql |
Site registration (origins, callbacks, staff/2FA policy): portal: ziteox-admin/supabase/migrations/20261031200000_app_site_registration.sql and productionHandoffSites() in portal: packages/auth/src/handoff/registry.ts.
| App key | Origins / callback (seed) | Staff | 2FA |
|---|---|---|---|
admin | https://admin.ziteox.com → /auth/handoff | required | required; max age 43200s (12h) |
client | https://client.ziteox.com → /auth/handoff | no | no |
Memberships, invites, connections
| Table | Role |
|---|---|
core.apps | Catalog: admin, client, rail (+ handoff policy columns) |
core.app_roles | Ranked roles per app |
core.app_memberships | User ↔ app (± org) grants; admin org must be null |
core.app_invites | Email invites into an app role |
core.app_connections | Per-user first/last handoff use per app |
Migration: portal: ziteox-admin/supabase/migrations/20261029220000_app_role_registry.sql, …/20261101000000_app_connections.sql.
TS registry / ceiling: portal: packages/auth/src/roles/registry.ts, ceiling.ts. Invite accept surfaces on Account (/invite/accept).
Cross-app APIs / service tokens
| Mechanism | What |
|---|---|
| MCP bearer tokens | Prefix zxmcp_; stored hashed in core.mcp_service_tokens (expires_at required). Issued from admin (portal: ziteox-admin/src/lib/mcp-service-tokens.ts); used on portal: ziteox-admin/src/app/api/mcp/route.ts. Shared identity helpers: portal: packages/auth/src/identity/. |
| Device authorization | Account /api/device/* + /device UI for agent pairing (RFC 8628). |
| Site secrets | Per-portal handoff client secrets (env names such as ZITEOX_SITE_SECRET on admin/client; Account-side site secret env names documented in Account Cloudflare/env examples) — values never in Forge docs. |
| Schema routing | Not a network API — shared PostgREST access with schema wrap. |
There is no shared browser session across admin and client. Cross-app automation goes through Account handoff, MCP tokens, or service-role server paths — not a parent-domain cookie.
Domains (defaults in code)
| Surface | Default origin |
|---|---|
| Account | https://auth.ziteox.com |
| Admin | https://admin.ziteox.com |
| Client | https://client.ziteox.com |
| Partner (related) | https://partner.ziteox.com |
From portal: packages/auth/src/sites.ts. Whether DNS/Vercel/Worker production currently points there: (unverified) from this docs pass alone.
Forge Core integration (decided 2026-11-01)
How admin (team-member Account side) will talk to Forge Core. The portal side is not built yet.
- Core project tokens (
zxcore_) are per project — never one member token spanning projects. - Admin registers projects and obtains tokens on a member’s behalf with Ed25519 admin assertions (
member_idclaim). - Admin shows one screen listing a member’s tokens across all their projects via Core
GET /v1/admin/members/:memberId/tokens(local-only today). - Spec: Admin portal integration.
Related
Sources
portal: README.md,packages/README.mdportal: packages/auth/(sites.ts,cookie-options.ts,handoff/,roles/,identity/)portal: packages/supabase-routing/src/index.tsportal: ziteox-admin/src/app/auth/,ziteox-client/src/app/auth/portal: ziteox-auth/src/app/api/handoff/token/route.tsportal: ziteox-admin/supabase/migrations/20261029210000_auth_handoff_codes.sqlportal: ziteox-admin/supabase/migrations/20261029220000_app_role_registry.sqlportal: ziteox-admin/supabase/migrations/20261031200000_app_site_registration.sqlportal: ziteox-admin/supabase/migrations/20261101000000_app_connections.sqlportal: ziteox-admin/supabase/migrations/20261012160000_mcp_service_token_expires_at.sqlportal: docs/auth-shared-layer-plan-2026-10-29.md- Forge:
docs/core/admin-portal-integration.mdx