8.3 KiB
ZitPlane developer architecture
Reviewed source baseline: 40af5007503501643d1e9ad2ab3939ba57dab5f9 (2026-11-22). Build/runtime/deploy acceptance: pending.
1. Component ownership
| Layer | Source of truth | Responsibility | Status |
|---|---|---|---|
| Identity backend | Official ZITADEL ghcr.io/zitadel/zitadel:v4.20.4 pinned in deployment/docker/compose.backend.dev.yaml |
Identity/OIDC, policies, built-in Console; not copied into Git | Development Compose source only |
| Data | postgres:17.10-alpine in same Compose |
Local disposable-but-persistent ZITADEL database | Configured; runtime not verified |
| Login UI V2 | auth/ui/v2/apps/login/ + nested workspace deps |
Official upstream Next.js login/recovery/MFA UI | Import-only, upstream v4.20.4, original behavior, build pending |
| User account portal | users/ui/ |
Separate Next.js read-only user profile and security landing pages, Auth.js OIDC relying party | Source implemented; build/flows pending |
| Dev proxy | Traefik v3.7.7 in P02 Compose |
127.0.0.1:8080 loopback entry to prebuilt Login V2 + ZITADEL API |
Configured; live routing pending |
| Production stack | Not present | Future Coolify routing/TLS/volumes/backups | NOT IMPLEMENTED |
2. Identity and session flow (designed/implemented in source, not proven)
- Browser visits portal at
/account.users/ui/src/app/(protected)/layout.tsxcallsrequireIdentity()insrc/lib/identity.ts. - Missing or expired user identity redirects to
/signin; public form uses Auth.jssignIn("zitadel"). - Auth.js provider is defined in
users/ui/src/auth.tsusing configured issuer, client ID/secret, PKCE/state/nonce andopenid profile emailscopes. - Browser is redirected to ZITADEL's identity/login service (external issuer). Auth.js handles callback at
/api/auth/callback/zitadel, JWT session cookies and local portal session. - The
sub/providerAccountIdis the immutable identity key used by the portal; email is only display data. - Protected pages and
GET /api/account/mecheck for nonemptysession.user.id. The session callback clears that ID if token expiry is absent or in the past. - Portal sign-out calls Auth.js
signOut; it does not guarantee ZITADEL-wide SSO logout. Token refresh, federated logout and user edits are future work.
Boundary: P02 Compose still uses the official prebuilt zitadel-login image. It does not build or run the imported P03 Login UI source, and does not run the P04 account portal. These are P05+ integration tasks.
3. Configuration and data flow
core/backend/zitadel/dev.py -> ignored root .env (local random secrets only) -> deployment/docker/compose.backend.dev.yaml -> local Postgres/ZITADEL/prebuilt Login/Traefik.
users/ui/.env.example is documentation only for ZITADEL_ISSUER, ZITADEL_CLIENT_ID, ZITADEL_CLIENT_SECRET, AUTH_SECRET, AUTH_URL, AUTH_TRUST_HOST. Runtime credentials must not be committed. The portal has no own database in P04.
4. Safety properties and constraints
- Keep production and development secrets/volumes entirely separate; never use loopback HTTP Compose publicly.
- No browser-side admin PAT/master key; Account Portal uses its own confidential OIDC client.
- Authentication logic, cookies, session/expiry, callbacks and passkey behavior are protected from UI-only edits.
- Login V2 upstream code is vendor-imported under its exact workspace-relative paths; preserve provenance and license notices.
- Later production must verify trusted proxy headers, HTTPS origin, cookie scope, WebAuthn domain and ZITADEL health/readiness.
- ZITADEL Console handles identity admin; app-specific billing and entitlements stay in external SaaS apps.
5. Implementation status versus acceptance
P01 folder foundation committed. P02 local Compose source completed (prior 3/3 static tests; no Docker). P03 source import integrity audited (638/638 Git blobs), but no build. P04 Account Portal scope audit passed; no dependency install, lockfile, TypeScript build, E2E or CI run. All runtime behavior remains unverified.
See docs/PHASES.md, docs/P02-EVIDENCE.md, docs/P03-SOURCE-IMPORT.md and docs/P04-ACCOUNT-PORTAL.md for exact historical evidence.
P05-OIDC-07 — proposed production trust-boundary topology, NOT deployed
- Public issuer
https://auth.vib.tools(proposed only): one TLS-terminating trusted ingress;/ui/v2/login/**→ imported Login V2 private 3000, all other ZITADEL API/discovery and/ui/console/**→ official Go private 8080 via h2c for gRPC/gRPC-Web; static exact Host/forwarded-header allowlist, no direct host backend/DB ports. - Independent relying-party
https://account.vib.tools(proposed only): separate HTTPS ingress to Auth.js Account, exact registered confidential Web-client callbackhttps://account.vib.tools/api/auth/callback/zitadel. Keep user sessions/cookies host-scoped, protected APIs/no-store and issuer/client/subject validation. - Security/operations boundaries: dedicated
IAM_LOGIN_CLIENTservice identity separate from break-glassIAM_OWNER; exactly 32-byte ZITADEL master key protected with separately encrypted Postgres backups/restores; safe Login V2 Console cutover/rollback; digest-locked image provenance and monitoring. Existingdeployment/docker/compose.backend.dev.yamlremains localhost HTTP/dev only; no real production domains/DNS/certificates/secrets were read or changed. Seenotes/P05-OIDC-07.md,docs/P05-OIDC-07.md.
P05-OIDC-08 — synthetic contract vs real production architecture
The new deployment/production-contract/compose.ci.yaml and routing-policy.json are not deployable or active ingress; they model the proposed HTTPS issuer https://auth.vib.tools, https://account.vib.tools separate Account origin, exact callback, ZITADEL h2c private API/Console, Login V2 private 3000, edge Host/Forwarded sanitization and secret references. All images are synthetic.invalid, replicas zero, private network and no ports. They are separate from untouched deployment/docker/compose.backend.dev.yaml, existing real Account/Auth.js, imported Login V2 source and production infrastructure. Run #101 passed Compose structural parse but FAILED strict normalized Compose RUNTIME_BEHAVIOR validation; no negative fixtures ran, so the contract is NOT security accepted. Existing real custom Login CI Run #99 remains accepted in its original development-only boundary. See notes/P05-OIDC-08.md.
P05-OIDC-09 — 2026-11-23 production release preflight (current evidence supersedes older acceptance status)
Repository-backed SOURCE VERIFIED: official Go ZITADEL is referenced by deployment/docker/compose.backend.dev.yaml version tag v4.20.4 and is not vendored; it is a development-only HTTP localhost Compose. Imported upstream Login v4.20.4 has tracked Dockerfile, frozen PNPM source lock, CI build helper; the only imported custom image accepted is disposable Run #99 and has been cleaned, not a signed/published release. Account Portal has a checked-in users/ui/package-lock.json, a standalone Next.js config and confidential Auth.js provider, but no tracked Account production OCI Dockerfile or released image. Earlier P04-era claims of no lock/build acceptance here are historical, NOT current.
CI VERIFIED only: Run #99 imported custom Login real browser OIDC/PKCE/Auth.js in disposable localhost CI, and Run #105 manual synthetic static proposed production contract, 48/48 malformed-case rejects PASS. LIVE NOT VERIFIED/BLOCKED: public auth.vib.tools canonical HTTPS issuer and account.vib.tools callback, valid TLS/Host+forwarded/h2c routing, immutable signed image registry releases, secure master key/PAT/secret custody, independent IAM_OWNER, matching encrypted PG restore, Console/MFA/passkeys/recovery, second-app SSO and monitoring. The deployment/production-contract files are reserved synthetic.invalid zero-replica data, NOT real production topology.
An independently approved phased implementation is mandatory; no production go-live decision follows from static CI. See notes/P05-OIDC-09.md forensic matrix/stop gates and docs/P05-OIDC-09.md operator sequence. No code/CI/deployment changed in P05-OIDC-09.