feat: establish ZITADEL OIDC account portal foundation

This commit is contained in:
Vib Tools committed 2026-11-22 04:25:33 -08:00
1 parent 4404849fc4
commit 40af500750
28 files changed
+898 -10

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ ZitPlane is a central **identity and account-management platform**, not a billin
- **ZITADEL** (official Go server): identities, authentication, OIDC, security policies, projects, admin console.
- **Login V2** (customized upstream Next.js app): branded signup, sign-in, recovery and challenge screens.
- **Account portal** (custom Next.js app): user-scoped profile/security/linked identities.
- **Account portal** (P04 separate Next.js App Router source at `users/ui/`): standard ZITADEL OIDC + Auth.js, server-protected overview/read-only profile/security navigation, user-scoped API. Real user editing and security-device management are **not implemented yet**; CI and live integration remain pending.
- **PostgreSQL**: persistent ZITADEL storage. Do not expose directly to the Internet.
- **Coolify / Compose**: one Git deployment definition, isolated services and persistent volumes.
+2 -2
View File
@@ -4,7 +4,7 @@
- P01 Foundation: committed.
- P02 Local backend: configuration and helper implemented; **runtime verification blocked** because Docker is not installed on the connected Windows PC.
- P03 Login V2: official v4.20.4 Next.js source and upstream pnpm/Nx/client/proto dependencies **imported** under `auth/ui/v2/`; builds/dependency installation and runtime verification **intentionally deferred to Gitea Actions**.
- P04 Account Portal: not started.
- P04 Account Portal: independent Next.js/App Router + ZITADEL OIDC/Auth.js source and compact profile/security UI implemented under `users/ui/`; **no dependency install, lockfile, build, tests or runtime validation performed**. See `users/ui/README.md` and `docs/P04-ACCOUNT-PORTAL.md`.
## Getting local ZITADEL running
1. Install and launch Docker Desktop with Linux containers. Verify `docker compose version`.
@@ -20,7 +20,7 @@ The proxy is **loopback-only and HTTP-only**. It is for disposable local develop
## Where to change code (future phases)
- Official Go server: **no core source edits**, see `core/backend/zitadel/`.
- Auth UI changes: `auth/ui/v2/apps/login/src/` (upstream workspace kept intact). See `auth/ui/v2/README.md` for beginner-friendly locations.
- Account UI changes: `users/ui/` after P04.
- Account UI changes: `users/ui/src/app/`, `users/ui/src/components/`, and `users/ui/src/styles/`; protected identity/auth integration lives in `users/ui/src/auth.ts` and `users/ui/src/lib/` (no visual-only changes there).
- Shared UI/components: `packages/` only if required by imported code.
- Local Docker infrastructure: `deployment/docker/`.
+43
View File
@@ -0,0 +1,43 @@
# ZitPlane P04 — Account Portal Source Evidence
Date: 2026-11-22
Approved baseline: `4404849fc4bd30c7b4b7cabe7caed54cbd7cd37d`
Scope: `users/ui/**` + narrow `README.md` and `docs/**`; **P02/P03 source READ-ONLY**.
## Implemented
- Separate Next.js `16.4.3` / React `19.2.6` App Router source, Auth.js `next-auth@5.0.0-beta.32` for ZITADEL.
- OIDC Authorization Code + PKCE, state and nonce checks, dedicated confidential web client, app-specific JWT session (max 1h).
- Validated runtime-only issuer, app origin, client credentials and session secret; production requires HTTPS.
- No mock production user, browser-stored token, unsafe callback URL, reused privileged admin PAT or server master key.
- Server-side protected layout plus per-page and read-only API identity guards. **User ID is an immutable OIDC `sub`**, never email; token expiry cleared when absent/expired.
- Public `/signin`, protected overview/profile/security, and `GET /api/account/me` with user-only response / 401 and no-store.
- Local-only sign-out, explicitly **not a global SSO logout**.
- Responsive foundation UI, CSS media-query dark mode, no UI dependency on the unmodified Login V2 build.
- Read-only profile and links to existing ZITADEL self-service only. Editing profile/MFA, billing, subscription and cross-app admin remain out-of-scope.
## Intentional omissions / acceptance gates
The user explicitly excluded all **local builds, tests, dev servers and deployments**, and requested CI in a later phase. As a result, the following are **NOT VERIFIED**:
1. npm dependency compatibility and reproducible lockfile (no lockfile generated or installed in P04).
2. TypeScript typechecking, Next.js production build, React rendering and Auth.js provider behavior.
3. Real ZITADEL OIDC login, callback, session expiry, safe logout and user-scoped API 401/200 behavior.
4. HTTPS proxy/host forwarding, WebAuthn/SSO, account self-service permissions, Docker/Coolify integration.
Auth.js v5 is still beta in the pinned version, so CI should validate compatibility and consider a stable alternative before production approval. The beta.32 version includes a patch for advisory GHSA-8fpg-xm3f-6cx3; user identity guards use `session.user.id` rather than merely `!!session`.
**P04 source-only audit (2026-11-22):** 28 staged approved files (23 under `users/ui/**`, 5 approved README/docs paths), P02/P03 changes **0**, staged secret files **0**, `git diff --cached --check` **PASS**. Existing unrelated untracked `AI_INSTRUCTIONS.md` was left untouched. This audit verifies repository scope and basic patch hygiene, **not** authentication behavior or build correctness.
**No Gitea Actions workflow is created or run in P04.** Source-only Git scope inspection is permitted and does not constitute tests/build. Do not declare runtime acceptance until focused disposable CI and staging checks pass.
## Next steps
- P05: approve integration scope and CI foundation, including lockfile generation, version/security review and disposable ZITADEL OIDC configuration; no live deployment.
- P06: compact branded UI redesign limited to page/components/styles while preserving authentication contract.
- P07: hardened deployment with configured public domains, TLS, persistent secrets and backups after acceptance.
References:
- https://zitadel.com/docs/sdk-examples/nextjs
- https://authjs.dev/getting-started/installation?framework=Next.js
- https://authjs.dev/getting-started/session-management/protecting
- https://github.com/nextauthjs/next-auth/security/advisories/GHSA-8fpg-xm3f-6cx3
+7 -2
View File
@@ -25,8 +25,13 @@ Implement one explicitly approved phase at a time. Keep out-of-scope files, exis
- P02 prebuilt Login UI remains configured in the development Compose; do **not** replace it or call runtime acceptance complete.
- Evidence and known gaps: `docs/P03-SOURCE-IMPORT.md`. CI workflow not part of this scope.
## P04 — Account portal foundation (proposed, NOT approved)
OIDC-protected basic account self-service skeleton; no fake production authentication.
## P04 — User Account Portal foundation (APPROVED 2026-11-22; SOURCE IMPLEMENTED)
- **Baseline:** `4404849fc4bd30c7b4b7cabe7caed54cbd7cd37d`.
- **Exact Write Scope:** `users/ui/**`, narrow project `README.md` and relevant `docs/**` (phase/evidence/architecture/developer guide). **P02/P03 source read-only.**
- Separate compact Next.js portal, ZITADEL OIDC/PKCE authentication, server-protected user routes, read-only profile and security settings structure.
- Real OIDC only; no fake production auth, browser admin credentials, billing or user-management mutation endpoints. Existing ZITADEL core/Login V2 untouched.
- Explicitly **no local builds, tests, dev server, Docker or deployment**. Source-level audit only, Git commit and approved Gitea main push. Gitea Actions testing deferred; no CI workflow in this scope.
- Evidence and pending runtime acceptance: `docs/P04-ACCOUNT-PORTAL.md`.
## P05 — Integration (proposed, NOT approved)
Local development, shared UI tokens as needed, production-safe Docker topology, routing drafts, tests/docs. No live deployment.