Files
ZitPlane/notes/P05-OIDC-04.md
T

75 lines
9.4 KiB
Markdown
Raw Normal View History

# P05-OIDC-04 — Private Port-8080 Listener RCA & Real OIDC Acceptance
**Date:** 2026-11-23 (Asia/Dhaka)
**Approved baseline:** `89bc3f21af53e481c68ee06c8eb120e30b855038`
**Prior CI evidence:** Gitea [Run #93](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/93), job #206, source `7b80f411b2981e2274d171c12596301ed757b768` — completed FAILURE. Healthy backend/proxy PASS; socat `SOCKET_BIND_ERROR`, Python fallback `ADDRESS_IN_USE` on private port 8080; client/user/browser NOT EXECUTED; owned-only cleanup PASS.
## PRE-SOURCE-CHANGE Scope Lock and plan
This note is committed **before the P05-OIDC-04 source edit**.
- **Source write:** `tests/ci/oidc_e2e/run.sh`; `tests/ci/oidc_e2e/forwarder.py` only for necessary target selection; at most one isolated helper in `tests/ci/oidc_e2e/` if justified.
- **Docs write:** `notes/**`, relevant `project/**`, `docs/**`, associated README/MINIFEST where necessary.
- **Strict read-only:** `.gitea/workflows/**`, `core/backend/zitadel/**`, `deployment/docker/**`, `auth/ui/v2/**`, `users/ui/**`, original Account/Auth.js, package manifests and locks, Gitea runner configuration, production and secrets, unrelated files.
- Preserve untracked root `AI_INSTRUCTIONS.md`. No local build, app tests, dev servers, real humans, production deployments, tags, releases or auth bypass.
- **CI budget:** one newly approved manual isolated workflow dispatch, no rerun/repeat, and mandatory existing `always()` owned-only cleanup.
## Read-only RCA baseline
The CI-only run script starts both its socat and fallback sidecars with `--network container:$proxy_id`; each binds IPv4 `127.0.0.1:8080`. Because they reuse the **same Traefik network namespace**, a pre-existing listener there makes *both* impossible to start. The original developer Compose routes Traefik web at `:80` and ZITADEL API at `:8080` in **a different service namespace**; which process, if any, owned proxy-local TCP 8080 in Run #93 is UNKNOWN. Run #93 resource teardown is already verified, so a retrospective namespace socket/proc inspection is impossible.
## Approved focused implementation
1. Before any forwarder bind, inspect `/proc/net/tcp{,6}` inside the disposable proxy network namespace, and correlate TCP LISTEN port 8080 socket inodes with `/proc/*/fd` and `/proc/*/comm` inside the same proxy PID namespace. Emit only bounded numeric inodes/PIDs and sanitized process name/status; no argv, environment, HTTP requests, tokens, payloads or raw logs. Record `NONE` or `UNKNOWN` faithfully; don't invent an owner.
2. Resolve confirmed **shared namespace bind contention** by using the already-disposable private Compose Docker network for a dedicated run-labeled forwarder namespace (not the proxy's namespace). Forward opaque bytes from its loopback `127.0.0.1:8080` to private DNS `proxy:80`, never a host-published port. This preserves original `http://localhost:8080` issuer/Host requirements. Provisioning and Chromium/Account containers join the forwarder's namespace instead of Traefik's. Unmodified original Compose, Login V2, Auth.js and negative-test contract remain in effect.
3. Validate exact private HTTP 200 *before* ephemeral credentials/client/user creation; check image immutable digest/entrypoint, isolated resource ownership and mandatory teardown.
4. One focused source/security/diff audit and Gitea main commit/push. Dispatch ONE authorized Gitea workflow acceptance run on exact tested SHA. Inspect actual run/job log and PASS/FAIL/NOT EXECUTED gates for Docker, socat/fallback, private 200, official project/client/user, real Chromium Login V2, S256 PKCE/state/nonce, genuine Auth.js session/protected page/API, negative cases, logout and all owned cleanup.
5. Final docs-only synchronization and Git main/remote SHA verification without new CI. If blocked, distinguish the exact failure and downstream unexecuted gates; do not claim authenticated acceptance or a listener owner absent reliable evidence.
**Pre-run disposition:** Not yet executed in P05-OIDC-04; real authenticated OIDC remains BLOCKED pending one terminal disposable CI result.
## Terminal Gitea CI acceptance — ONE authorized Run #95
**Evidence:** [Gitea Run #95](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/95), **job #209**, manual `workflow_dispatch` on `main`; tested **exact source SHA `79dac4f5bb76e1cee4dfaf61657c6e84268b3dfb`**, distinct from the later documentation commit. Started `2026-11-22T19:40:58Z`; completed `2026-11-22T19:46:22Z`. Run status `completed`, conclusion **`failure`**.
The approved source preparation was one documentation Scope Lock commit `1cf6d65f041137ba6c2ec1c6f452397db133be46` followed by one focused commit `79dac4f5bb76e1cee4dfaf61657c6e84268b3dfb` modifying ONLY `tests/ci/oidc_e2e/run.sh` and `forwarder.py`. Focused diff verified the isolated network strategy, never-opened host ports, private loopback-only binding, absent credentials/log payloads and unchanged original backend/Compose/Login/Account/lockfiles. No other CI dispatch, rerun, local app test/build or deployment.
Job #209 steps: #0 Git install **SUCCESS**; #1 checkout **SUCCESS**; #2 real disposable OIDC execution **FAILURE**; #3 mandatory owned-only cleanup **SUCCESS**.
| Exact acceptance gate | Result / safe evidence |
| --- | --- |
| Runner accepted job and exact source checkout | **PASS**; job #209 ran at `79dac4f5bb76e1cee4dfaf61657c6e84268b3dfb` |
| Docker/Compose and ownership preflight | **PASS**; `ZITPLANE_OIDC_DOCKER_PREFLIGHT_PASS` |
| No published host ports; isolated first-instance IAM_OWNER configuration | **PASS**; `ZITPLANE_OIDC_NO_PUBLISHED_PORT_AND_OWNER_CONFIG_PASS` |
| Four healthy disposable Postgres/ZITADEL API/official Login V2/Traefik services | **PASS**; `ZITPLANE_OIDC_FOUR_SERVICES_READY_PASS` |
| Direct private Traefik:80 readiness with exact Host `localhost:8080` | **FAIL**; `OIDC_CI_PRIVATE_PROXY_SOCKET_OR_HTTP_BLOCKED`; no returned status or precise failure errno/class |
| Proxy namespace port-8080 listener inode/PID/process forensics | **NOT EXECUTED**; guarded behind failing direct readiness |
| Socat immutable image validation and dedicated forwarder startup | **NOT EXECUTED** |
| Python immutable-image fallback and private port-8080 forwarding | **NOT EXECUTED** |
| Forwarded private localhost:8080 exact-Host HTTP 200 and issuer/discovery | **NOT EXECUTED** |
| Official ZITADEL disposable project and OIDC app/client creation | **NOT EXECUTED** |
| Official disposable verified test human creation | **NOT EXECUTED** |
| Real Chromium original Login V2 username/password | **NOT EXECUTED** |
| Authorization code, PKCE S256, state, nonce | **NOT EXECUTED** |
| Genuine Auth.js callback and authenticated Account session | **NOT EXECUTED** |
| Protected Account page and identity API | **NOT EXECUTED** |
| Anonymous and tampered callback rejection | **NOT EXECUTED** |
| Local logout and authenticated session invalidation | **NOT EXECUTED** |
| Mandatory owned-only cleanup | **PASS**; `ZITPLANE_BACKEND_CLEANUP_VERIFIED_PASS` and `ZITPLANE_OIDC_ALL_RESOURCES_CLEANED_PASS` |
### RCA boundary
Run #95 stopped **before** executing the new pre-bind listener inspection. Therefore the exact process owning proxy-local TCP 8080 remains **UNKNOWN**; the historical Run #93 `ADDRESS_IN_USE` evidence is not disproved, but **Run #95 did not reproduce or attribute it**. The run demonstrates that Compose healthy status is not equivalent to the separate network-namespace exact-Host HTTP probe. The observed probe error is intentionally generic (connection/socket/HTTP); neither Traefik failure nor runner outage nor authentication regression can be inferred from it. The remediation candidate in `79dac4f5bb76e1cee4dfaf61657c6e84268b3dfb` is **committed but unverified at runtime**, since socat/Python never started.
### Final P05-OIDC-04 acceptance and next exact proposal
**Phase source/Scope Lock audit:** COMPLETE. **Run #95:** TERMINAL FAILURE; **cleanup:** PASS. **Real authenticated OIDC acceptance:** BLOCKED/NOT EXECUTED. **Production readiness and MFA:** NOT VERIFIED. Preserve this distinction and no more CI dispatch in this phase.
**Next phase proposed, requires separate approval — P05-OIDC-04-A01 / direct private proxy readiness diagnostics:**
- **Write:** create `notes/P05-OIDC-04-A01.md` before any source changes; `tests/ci/oidc_e2e/run.sh` only for bounded, secret-safe direct `proxy:80` localhost Host readiness failure classification and conditionally justified finite retry; at most one strictly focused diagnostics helper under `tests/ci/oidc_e2e/` if absolutely needed; relevant `notes/**`, `project/**`, `docs/**` and manifests.
- **Strict read-only:** `tests/ci/oidc_e2e/forwarder.py`, all other CI harness files, `.gitea/workflows/**`, original backend/Compose/Login/Auth.js/Account, package manifests/locks, runner configuration, secrets, production and unrelated files.
- Inspect independent proxy container state, namespace-local TCP connection class (refused/timeout), exact Host readiness HTTP status **without response body or sensitive URLs**. Differentiate actual startup race from route/policy failure *before* changing timeouts. Preserve one-run labels, no public ports, issuer, negative tests and always-owned cleanup.
- Focused source audit, one independently approved disposable Gitea CI run with exact tested SHA, full OIDC gates if reachable, terminal cleanup, final docs commit and remote SHA verification. No repeated runs, local builds, real people, production, tags or releases.
No claim of successful socket attribution or authenticated login is permitted from Run #95.