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,6 +10,7 @@ This is the **developer-focused implementation history**. `notes/CHANGELOG.md` i
| 2026-11-22 | P04 | `users/ui/` Account Portal OIDC, pages, styling, read-only identity API | `40af500`; `docs/P04-ACCOUNT-PORTAL.md`; no build/CI |
| 2026-11-22 | DOCS-01 | Documentation governance; developer architecture, reviewed first-party function/file/page mapping and 701-path source inventory; user manual/setup/status/troubleshooting | Documentation complete; manifest/link/source-scope audit PASS; `notes/DOCS-01.md`, local commit SHA via Git history |
| 2026-11-22 | P05-CI-01 | `.gitea/workflows/p05-ci.yml`, `tests/ci/**`, Account npm lock, Login pnpm importer reconciliation and in-scope Alpine Git checkout correction | Run #81 overall FAIL; 2 jobs PASS, 2 FAIL; Login 1219/1219 tests PASS, Account TS2345 and Docker checkout blocked; `notes/P05-CI-01.md` |
| 2026-11-22 | P05-CI-02 | Type-safe Auth.js subject narrowing; Gitea CI negative API/OIDC tests, Postgres restart persistence and Moderate advisory detail inventory | CI result pending; `notes/P05-CI-02.md`, `docs/P05-CI-02.md` |
## Required entry for each future change
+9
View File
@@ -37,6 +37,15 @@ The P02 Compose has a fixed named network `zitplane-backend-dev-internal` and lo
Reference: `notes/P05-CI-01.md`, `docs/PHASES.md`, `.gitea/workflows/p05-ci.yml`, `tests/ci/`.
## P05-CI-02 Narrow Auth.js and CI additions
- `users/ui/src/auth.ts` `callbacks.session`: `const subject: string = typeof token.zitadelSubject === "string" ? token.zitadelSubject : "";` explicitly narrows the JWT claim. Session still sets `id` only when subject nonempty and OIDC access-token expiry is in the future. `users/ui/src/types/next-auth.d.ts` was not changed. This addresses Run #81's `TS2345` (`user.id: {}`) without a cast or altered PKCE/state/nonce.
- `tests/ci/account_negative.py` + Account job: anonymous identity API 401/no-store and protected route redirect; no fake logged-in account. `tests/ci/oidc_discovery.py`: issuer/origin/JWKS negative contracts plus actual disposable ready/discovery/JWKS. Tests are CI-only.
- `tests/ci/advisory_triage.py`: parse live npm/pnpm registry JSON into advisory IDs, package, affected range, patch availability. Prior high/critical failure threshold maintained; no dependency versions changed.
- Backend CI: after safe Docker/network preflight and startup, write one marker in **disposable Postgres database `postgres`**, restart its container, verify marker persists and ZITADEL becomes ready, then test OIDC discovery/JWKS. Always cleanup only the current CI Compose project and its volumes; failure must remain visible.
- Corrected Alpine Git checkout from P05-CI-01 is exercised by the new run. Fixed name `zitplane-backend-dev-internal` is a known isolation limitation: existing network triggers fail-closed instead of reuse.
- No full interactive user login callback, MFA, Admin Console user session or production TLS verification; separate future scope.
## Verified Gitea Run #81 and source follow-up
Initial dispatched commit `42b79362c13b9dbb07f85a58ad278742d91b1f5b`. Two PASS: Login V2 frozen reproducible install, production build and 1219/1219 upstream unit tests; dependency advisory gate at high/critical only (18 moderate findings outstanding). Two FAIL: Account Portal TS2345 Auth.js session callback type mismatch; Alpine backend actions/checkout fallback `Not found` because Git missing before checkout. The Docker runtime and full interactive OIDC flow **were not executed**.
+11
View File
@@ -96,6 +96,17 @@ These paths describe **source**, not a verified running app. Do not infer API co
| `project/CI-ARCHITECTURE.md` | Runner/CI security and runtime-verification boundaries |
| `notes/P05-CI-01.md`, `docs/P05-CI-01.md` | Pre-change plan and operator-facing CI evidence |
## P05-CI-02 file ownership update
| Path | Verified narrow function |
| --- | --- |
| `users/ui/src/auth.ts` | `callbacks.session` optional JWT subject type narrowing; no change to provider, policy or PKCE/state/nonce |
| `.gitea/workflows/p05-ci.yml` | CI-only Account negative smoke, Postgres restart persistence, registry advisory JSON collection and cleanup status |
| `tests/ci/account_negative.py` | Anonymous API 401 and protected route redirect CI probe |
| `tests/ci/advisory_triage.py` | Nonmutating npm/pnpm vulnerability inventory with IDs and patch availability |
| `tests/ci/oidc_discovery.py` | Read-only disposable issuer/JWKS negative validation and live metadata smoke |
| `notes/P05-CI-02.md`, `docs/P05-CI-02.md` | Pre-change Scope Lock, actual Gitea CI results and user/operator limitations |
## Other first-party folders
`packages/README.md`: intentionally empty shared-package placeholder, not the upstream `auth/ui/v2/packages/`.
+7
View File
@@ -65,6 +65,13 @@
`tests/test_backend_dev.py`: `BackendDevContract.test_initialization_is_private_and_idempotent`, `test_compose_local_only_and_version_pinned`, `test_secrets_ignored`. They validate **static P02 contracts**, not real authentication or Docker.
## P05-CI-02 Auth.js and CI helpers
- `callbacks.session({session, token})` (`users/ui/src/auth.ts`): before populating `Session.user.id`, explicitly narrow optional/unknown JWT claim using `typeof ... === "string"`; only nonempty string + future expiry gives a user ID, otherwise `""`. Fixes TypeScript return typing; protects previously implemented auth behavior.
- `tests/ci/advisory_triage.py`: `read_report` rejects invalid/network-error JSON; `triage_pnpm` lists registry advisory IDs, affected modules/versions and available fixes; `triage_npm` summarizes direct/transitive npm vulnerable packages and their advisory links; `main` dispatches formats.
- `tests/ci/account_negative.py`: `NoRedirect` prevents following protected-account redirects; `main` validates 401/no-store API and redirects for anonymous users against a disposable CI Account Portal instance.
- `tests/ci/oidc_discovery.py`: `verify_metadata` enforces exact disposable issuer/origin for OIDC endpoints, `verify_jwks` rejects empty/malformed public key sets, `verify_negative_contracts` exercises malformed fixtures, `fetch` stays within CI Docker proxy, `main` probes live disposable OIDC.
## Future update minimum for each function
Record: exact path, function name/signature, callers, inputs/outputs, error behavior, security assumptions, user-visible effect, tests/CI reference, phase + commit. Do not speculate from a filename alone.
+22 -20
View File
@@ -1,25 +1,23 @@
# Source inventory ? all Git-tracked paths
**Snapshot:** 2026-11-22, P05-CI-01 staging based on baseline `7ecf531`. Files listed from the local Git index; final Git commit records the snapshot.
**Snapshot:** 2026-11-22, P05-CI-02 staged source on baseline `42adaba`; before final CI acceptance.
**Tracked paths: 714.** Excludes ignored secrets, local builds and untracked `AI_INSTRUCTIONS.md`.
**Exact tracked file paths: 718.** This is a locator and does not assert every upstream file/function was independently audited or tested. Untracked `AI_INSTRUCTIONS.md` and ignored secrets are excluded.
This is an exact **source location inventory**, not an audit of each upstream Login V2 function or proof of CI success. For behavior see `project/FILE-MAP.md`, `project/FUNCTIONS.md` and the phase evidence.
| Group | Files | Ownership |
| Top-level group | Files | Ownership |
| --- | ---: | --- |
| `(repository root)` | 6 | Main Git/project config and documentation navigation |
| `.gitea` | 5 | Gitea CI workflows and owner documentation |
| `auth` | 639 | Pinned upstream Login V2 and dependency workspace |
| `core` | 2 | Official backend orchestration; not Go core source |
| `deployment` | 2 | Local-only P02 Compose |
| `docs` | 13 | User/operator docs and evidence |
| `notes` | 5 | Phase plans and logs |
| `packages` | 1 | Future first-party shared component placeholder |
| `project` | 10 | Developer knowledge and source inventory |
| `scripts` | 1 | Future development script placeholder |
| `tests` | 6 | P02 static and P05 CI-only verification scripts |
| `users` | 24 | P04 Account Portal and P05 lockfile |
| `(repository root)` | 6 | Git-tracked content |
| `.gitea` | 5 | Gitea manual CI files |
| `auth` | 639 | Original Login V2 upstream imports |
| `core` | 2 | ZITADEL backend orchestration |
| `deployment` | 2 | Dev-only Docker Compose |
| `docs` | 14 | Operator/user guides and CI evidence |
| `notes` | 6 | Pre-change plans and phase logs |
| `packages` | 1 | Shared package placeholder |
| `project` | 10 | Developer architecture and source map |
| `scripts` | 1 | Script placeholder |
| `tests` | 8 | Backend and CI scripts |
| `users` | 24 | Account Portal and Auth.js |
## Exact Git-tracked paths
@@ -692,7 +690,7 @@ This is an exact **source location inventory**, not an audit of each upstream Lo
- `deployment/README.md`
- `deployment/docker/compose.backend.dev.yaml`
### docs ? 13 files
### docs ? 14 files
- `docs/ARCHITECTURE.md`
- `docs/DEVELOPMENT.md`
@@ -702,18 +700,20 @@ This is an exact **source location inventory**, not an audit of each upstream Lo
- `docs/P03-SOURCE-IMPORT.md`
- `docs/P04-ACCOUNT-PORTAL.md`
- `docs/P05-CI-01.md`
- `docs/P05-CI-02.md`
- `docs/PHASES.md`
- `docs/README.md`
- `docs/SETUP-GUIDE.md`
- `docs/TROUBLESHOOTING.md`
- `docs/USER-GUIDE.md`
### notes ? 5 files
### notes ? 6 files
- `notes/CHANGELOG.md`
- `notes/DOCS-01.md`
- `notes/MINIFEST.md`
- `notes/P05-CI-01.md`
- `notes/P05-CI-02.md`
- `notes/README.md`
### packages ? 1 files
@@ -737,11 +737,13 @@ This is an exact **source location inventory**, not an audit of each upstream Lo
- `scripts/README.md`
### tests ? 6 files
### tests ? 8 files
- `tests/README.md`
- `tests/ci/MINIFEST.md`
- `tests/ci/README.md`
- `tests/ci/account_negative.py`
- `tests/ci/advisory_triage.py`
- `tests/ci/oidc_discovery.py`
- `tests/ci/source_contract.py`
- `tests/test_backend_dev.py`