fix(ci): narrow Auth.js subject and extend disposable P05 verification

This commit is contained in:
Vib Tools committed 2026-11-22 05:24:04 -08:00
1 parent 42adaba004
commit c27fe3d323
23 files changed
+415 -45

No files matched your search

+1
View File
@@ -10,5 +10,6 @@ This is the chronological **index**. Phase-specific scope/implementation evidenc
| 2026-11-22 | P04 | Account Portal OIDC and protected frontend foundation | `40af500`; patch/scope audit, CI deferred |
| 2026-11-22 | DOCS-01 | Knowledge folders, first-party file/function maps, exact source inventory, user guides and mandatory AGENTS documentation policy | Documentation implementation complete; focused manifest/link/scope audit PASS; Git SHA in DOCS-01 local commit, see [DOCS-01.md](DOCS-01.md) |
| 2026-11-22 | P05-CI-01 | Gitea verification workflow, dependency lock reconciliation, narrow checkout remediation | Run #81: 2 PASS/2 FAIL; 1219 Login tests PASS, Account TS2345 and Docker checkout blocked; see [P05-CI-01.md](P05-CI-01.md) |
| 2026-11-22 | P05-CI-02 | Narrow Auth.js TS2345 fix, disposable backend persistence/OIDC negative CI and Moderate advisory triage | Implementation in progress; see [P05-CI-02.md](P05-CI-02.md) |
Rules: Append new phases or fixes; never silently rewrite a past result. Separate **implemented**, **verified**, **blocked**, and **proposed**. Never log a user secret or personal data.
+1
View File
@@ -6,6 +6,7 @@
| [MINIFEST.md](MINIFEST.md) | File list and ownership; **MINIFEST is the exact required filename** | DOCS-01 / active |
| [DOCS-01.md](DOCS-01.md) | This documentation-governance change: baseline, scope, plan, implementation and closure | DOCS-01 / implementation complete |
| [P05-CI-01.md](P05-CI-01.md) | Scope/roots, allowed paths, implementation and Gitea CI acceptance evidence | P05-CI-01 / source complete, CI blockers open |
| [P05-CI-02.md](P05-CI-02.md) | Auth.js narrow patch, isolated Gitea CI gate, advisory triage and exact acceptance evidence | P05-CI-02 / in progress |
| [CHANGELOG.md](CHANGELOG.md) | Short append-only chronological phase log and links to detailed reports | DOCS-01 / active |
Update this manifest whenever any direct child file or directory changes. Use **actual source state**; a planned file must be labeled planned, not present.
+36
View File
@@ -0,0 +1,36 @@
# P05-CI-02 — Targeted Remediation & CI Acceptance
**Date:** 2026-11-22
**Baseline:** `42adaba0044ee5cb86e6e6bcfd4e00e5fe96ad00` (local `main` = Gitea `main`)
**State:** APPROVED / PRE-CHANGE SCOPE LOCK
**Previous CI evidence:** Gitea Run [#81](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/81), tested `42b79362c13b9dbb07f85a58ad278742d91b1f5b`, overall FAILURE.
## Exact approved write scope
- `users/ui/src/auth.ts` — B01 narrow session callback typing only.
- `users/ui/src/types/next-auth.d.ts` — only if needed; avoid otherwise.
- `.gitea/workflows/p05-ci.yml` — CI isolation/verification/triage/cleanup.
- `tests/ci/**` — focused CI-only OIDC negative/discovery/production and audit scripts, plus README/MINIFEST.
- `notes/**`, `project/**`, relevant `docs/**`, associated `.gitea/**/README.md` and `MINIFEST.md`; root `README.md`, `MINIFEST.md` only as necessary.
READ ONLY: `core/backend/zitadel/dev.py`, `deployment/docker/compose.backend.dev.yaml`, all `auth/ui/v2/**` original source and lockfile, `users/ui/package.json` / `package-lock.json`, portal UI pages/feature logic and all other files. Preserve unrelated untracked `AI_INSTRUCTIONS.md`.
**No local builds, local tests, dev servers, Docker, real credentials/users, production deployments, tags or releases.** Source-level preflight/diff is permitted. Only ONE new manually dispatched Gitea CI acceptance cycle; no repeated reruns to chase green checks.
## Root-cause evidence (before edits)
- **B01 / TS2345**: Run #81 job 165, `users/ui/src/auth.ts(14,61)` generic NextAuth config callback rejected; downstream `callbacks.session` at lines 50–65 returns inferred `user.id: {}` instead of `string`. The current ternary uses `valid ? token.zitadelSubject! : ""`; the inferred `token.zitadelSubject!` type is not a reliable string despite the boolean `valid` expression. Correct by independently narrowing the JWT subject using `typeof ... === "string"` before constructing the session, and preserve expiry fail-closed. No `as any`, disabling strict mode or weakening route guards.
- **B02 / Docker checkout**: Run #81 job 168 failed in `node:22-alpine` `actions/checkout@v4`: Git missing, archive fallback `Not found`. Current Gitea `main` already has pre-checkout `apk add --no-cache git` at workflow lines 106–110, not yet executed by CI. Current Compose uses fixed local-only network/port; refuse collisions and cleanup ONLY owned disposable project volumes. Verify Postgres volume survives service restart, then readiness, OIDC issuer/discovery/JWKS on disposable network. No edits to Compose or backend helper.
- **B03 / Moderates**: Run #81 job 167 passed HIGH/CRITICAL threshold, but `pnpm audit --prod` reported **18 MODERATE findings**, without individual package/advisory IDs. Account `npm audit` also found **1 MODERATE Next.js issue** with multiple GHSA IDs. Generate structured advisory inventory in CI using registry data, record package/affected range/available fix; no blind dependency upgrades.
- **B04 / OIDC**: `tests/ci/oidc_discovery.py` currently checks ready/discovery/JWKS only, not authenticated user callback, session, MFA or admin login. Add robust negative/issuer/JWKS tests, while keeping real login E2E explicitly BLOCKED until separately approved disposable user/client provisioning.
## Implementation plan
1. Narrow `users/ui/src/auth.ts` TypeScript narrowing patch, no auth flow change. Add CI negative contract probes and source contract checks.
2. Strengthen Gitea job: auth typecheck/build, Login frozen build/unit regression, JSON advisory triage alongside existing HIGH+ gates, disposable Docker preflight plus Postgres persistence/ready/discovery/JWKS verification and always cleanup.
3. Ensure job isolation: no shared Docker network/port takeover, no existing project teardown; fail-closed if daemon/capability/isolation unavailable. No real secrets. One CI run, read job logs and exact conclusions.
4. Update `project/`, `docs/`, `notes/`, manifests. Exact scope/security diff audit, Git commit and authorized Gitea `main` push, verify final remote/local SHA. Phase acceptance remains BLOCKED if required gates fail; never claim unexecuted E2E PASS.
## Verification ledger
**NOT STARTED.** Record run ID/SHA, exact terminal job statuses, advisory IDs and severity, Docker persistence/cleanup, remaining blockers and final Git SHA only after real evidence is received.