# P05-OIDC-01 — Disposable Real Browser Authentication Architecture **Approved baseline:** `f423c696544f28a42d6a5d1ad0acfd88a3b6f56d`. **Current status:** CI-only source implemented; **real user callback/session acceptance requires actual terminal Gitea evidence**. ## Source and trust boundaries | Exact first-party file | Main function / why it exists | | --- | --- | | `.gitea/workflows/p05-oidc-acceptance.yml` | Only manual Gitea Docker job, installs Git before checkout, executes CI-only harness and always calls owned-only teardown; never auto-runs on untrusted PRs | | `tests/ci/oidc_e2e/run.sh` | Numeric Gitea run-ID validation, refusal of existing fixed network/projects/volumes/.env, disposable P02 Compose startup with no host ports, CI-only loopback namespace and secret volume, invokes official API provisioning and Chromium test | | `tests/ci/oidc_e2e/compose.owner.override.yaml` | Add first-instance ephemeral IAM_OWNER machine PAT **only to the CI-owned API service**; official P02 developer Compose unchanged | | `tests/ci/oidc_e2e/provision.py` | `request()` restricted to localhost API + Host, validates issuer/discovery, creates real project/Account OIDC Web client and verified temporary human via official management/User v2 APIs, writes generated credentials to 0600 separate CI secret volume, suppresses secret/error-body logging | | `tests/ci/oidc_e2e/browser.sh` | Disposable Playwright Chromium image installs committed Account npm dependencies and pinned Playwright v1.58.2 inside container, not local developer PC | | `tests/ci/oidc_e2e/browser.cjs` | `main()` drives actual browser OIDC authorization, original Login V2 UI fields, Auth.js callback, authenticated ID/API/pages, anon/invalid callback negative checks and local session sign-out; no mock or injected sessions | | `tests/ci/oidc_e2e/cleanup.sh` | Only owner-labeled browser/forwarder containers and secret volume are removed, then existing `backend_cleanup.sh` removes and verifies run-marked Compose/DB/bootstrap state; fail-closed on unverified cleanup | | `tests/ci/oidc_e2e/{README.md,MINIFEST.md}` | Isolated harness guide, exact source ownership and constraints | ## Exact runtime topology The P02 backend routes ZITADEL at `http://localhost:8080` and prebuilt official Login V2 at `/ui/v2/login`. The pre-existing CI `compose.portless.override.yaml` removes the developer's host loopback bind. This phase uses an isolated Docker proxy network namespace, with a run-owned TCP forward from **namespace-local** localhost:8080 to Traefik:80. Both the one-off provisioning container and the Chromium/Account runner share that *private* namespace; nothing listens on the Gitea host's port 8080 or 3000. `users/ui/src/lib/env.ts` disallows HTTP issuer in production and permits only HTTP localhost when `NODE_ENV=development`. Running the unmodified Account Portal with `next dev` inside a disposable CI container is therefore intentionally a **development-origin functional acceptance**, not a claim of HTTPS/production security acceptance. `users/ui/src/auth.ts` has real NextAuth ZITADEL `checks: ["pkce","state","nonce"]`, nonempty subject and token expiry guards; this phase does not edit them. ## Identity/provisioning security A first-instance IAM_OWNER service user is created only inside disposable ZITADEL during initial setup, with its PAT written to the run-owned bootstrap volume and a short expiry. This is **not** the existing IAM_LOGIN_CLIENT service token used by the official Login V2. The IAM_OWNER token is mounted read-only **only to the provisioning Python container**, not to Chromium. The test app/client secret and randomly generated password are transferred via a separate run-labeled volume read-only to Chromium, and neither logs nor Git contain sensitive values. The test user's email is a verified `.invalid` address, not a real recipient; owner token, identity client and user are destroyed along with owned Postgres/bootstrap volumes. ## Verification contract - ZITADEL 4 services live, exact isolated portless config, authoritative issuer and OIDC discovery - IAM_OWNER PAT exists, official project/app/client/user APIs return valid required fields - Chromium's real authorization navigation contains response_type code, matching client/redirect, S256 challenge, state and nonce - Original Login V2 form receives the ephemeral username/password; browser follows a genuine authorization code exchange to the protected Account Portal - Actual `GET /api/account/me` returns created subject ID and no-store, HttpOnly session cookie; protected page valid - Anonymous API + protected page rejected; tampered callback fails closed; portal sign-out returns unauthenticated API - Always owned-only cleanup confirms browser, port forwarder, secret volume, Compose containers, network, DB and bootstrap credentials gone **Never equate** a static source check, issuer/JWKS check or successful redirect with a successful interactive login/callback. MFA/passkey, Admin Console human sign-in, production TLS and custom source-built Login V2 runtime wiring are future explicitly approved phases. ## References ZITADEL official endpoints and bootstrap specification: `https://github.com/zitadel/zitadel/blob/main/cmd/setup/steps.yaml`, `https://zitadel.com/docs/reference/api/management/zitadel.management.v1.ManagementService.AddOIDCApp` and `https://zitadel.com/docs/guides/integrate/login-ui/username-password`. Actual Gitea result: `notes/P05-OIDC-01.md`. ## Run #90 terminal evidence and network integration blocker Gitea manual [Run #90](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/90), tested `cbcd60e76ec909df4f9c5826adf7a3e2a899c73e`, **FAILED**, job #197. `run.sh` correctly validated runner Docker/ownership, portless Compose with disposable first-instance IAM_OWNER configuration and brought all four P02 services up healthy. It created a private `alpine:3.21` namespace-sharing TCP forwarder; that helper attempted to install `socat` with its installation output silenced. The following `provision.py::wait_until_ready()` could not reach the expected private `localhost:8080` after 70 seconds and raised `ZITPLANE_OIDC_PROVISION_BLOCKED`. **The reason the forwarder was not ready remains unproven** (container exit, package install, socket bind or reverse-proxy routing cannot be distinguished from the available log). Do not misattribute failure to ZITADEL client provisioning or browser authentication: both were **NOT EXECUTED**. The mandatory `cleanup.sh` step #3 succeeded and printed `ZITPLANE_BACKEND_CLEANUP_VERIFIED_PASS` + `ZITPLANE_OIDC_ALL_RESOURCES_CLEANED_PASS`. It removed only run #90-owned proxy namespace forwarder, separate ephemeral secrets volume, Compose containers, Postgres/bootstrap volumes and fixed CI network. **Backend bootstrap/cleanup PASS; full end-to-end OIDC acceptance BLOCKED.** Next P05-OIDC-02 should narrowly instrument/check forwarder startup before provisioning, use an approved pinned prebuilt image to avoid silent runtime package installation, verify exact **private** loopback listener/Host routing without any host port exposure, preserve original Go backend/Compose/Login/Auth.js and credentials isolation, then run **one separately authorized** Gitea acceptance cycle. No CI-only patch in P05-OIDC-01 was executed after Run #90. ## P05-OIDC-02 — isolated private forwarder reliability (source prepared) The previous Gitea Run #90 verified a healthy, portless P02 stack but did not capture the private socat sidecar's exit status or verify the 127.0.0.1:80 proxy independently; the true forwarder failure cause is **unknown**. The new narrow `run.sh` checks the private Traefik:80 `/debug/ready` with `Host: localhost:8080` first, then uses the published version-specific `alpine/socat:1.8.1.3` image (preinstalled `socat`), checks `Entrypoint == ["socat"]`, resolves the pulled tag to its immutable sha256 registry digest and **runs by digest**. There is no `apk add` at runtime. Container state/exit code and bounded local forwarded HTTP 200 readiness are checked **before official OIDC project/user provisioning**. Only safe stage/status markers are printed on failure; no HTTP bodies, cookies, callbacks or passwords. `provision.py::wait_until_ready()` now independently verifies HTTP 200 rather than attempting to parse the `/debug/ready` response as JSON; **all official management/client/human creation requests remain strictly parsed JSON and authenticated with the ephemeral IAM_OWNER PAT**. No other protected code, developer Compose, original Login V2 or Account auth source changed. The existing `cleanup.sh` continues to remove only run-labeled/owned resources. **New Gitea real-browser acceptance pending; this is not a verified login yet**. Exact plan/evidence: `notes/P05-OIDC-02.md`. ## P05-OIDC-02 terminal result — exact failure narrower than Run #90 Gitea [Run #91](https://dev.ivib.cc/vibtools/ZitPlane/actions/runs/91) on `4831165548feabc2c0a0d39d25c40e0d1bc23bb2`, job #198, overall **FAILURE**. Four official backend services and portless CI Compose PASS. A **direct** `GET /debug/ready` on Traefik private 127.0.0.1:80 with `Host: localhost:8080` **PASS**; the old "maybe proxy Host routing is down" theory is disproven for this run. The versioned prebuilt `alpine/socat:1.8.1.3` image entrypoint and immutable digest verified **PASS**, but when started in the proxy network namespace the sidecar reported `exited`, **exit code 1**. No startup stderr was retained; the specific binary/runtime/bind/flag error remains **unknown**, so no unsupported cause is asserted. The status-only `provision.py::wait_until_ready()`, project/client/human APIs, real browser password flow, PKCE/state/nonce, Auth.js callback, Account session/positive and negative tests were **NOT EXECUTED**. `always()` cleanup PASS: both `ZITPLANE_BACKEND_CLEANUP_VERIFIED_PASS` and `ZITPLANE_OIDC_ALL_RESOURCES_CLEANED_PASS`. Original backend, Compose, Login V2, Auth.js source, manifests and security rules unchanged. Next phase should restrict writes to CI-only startup diagnostics/forwarder, verify the new forwarder HTTP 200 **before** provisioning, preserve private network namespace and ownership checks, then exactly one independently authorized real browser CI acceptance. **No application auth bypass or production deployment**. ## P05-OIDC-03 — CI-only exit-class evidence and transparent Python loopback fallback Run #91 established an isolated private Traefik:80/Host HTTP 200 and a socat sidecar `exited 1`, but not the internal startup reason. `tests/ci/oidc_e2e/run.sh` now runs a single socat startup probe *before user/client provisioning*, checks container state and private forwarded HTTP 200, classifies only allowlisted error classes from the diagnostic sidecar's own stderr (never prints raw logs), and retains socat when healthy. If unhealthy, it verifies the run ownership label, deletes only that diagnostic container, then resolves the already-used official `python:3.12-alpine` to its registry sha256 digest and starts the `forwarder.py` byte relay in the **same run-owned Docker container name and Traefik network namespace**. No host port, new credentials, tokens or HTTP-body logging. Both paths must pass private `127.0.0.1:8080 /debug/ready` with exact Host before calling official APIs. `tests/ci/oidc_e2e/forwarder.py` uses Python stdlib `asyncio.start_server`, binds only IPv4 `127.0.0.1:8080`, proxies to namespace-local `127.0.0.1:80`, relays opaque bounded byte chunks and emits only fixed safe startup/relay status markers. No HTTP inspection, cookie extraction, IdP simulation or login bypass. Original provisioning APIs, Account Portal Auth.js, Chromium tests and owner-labeled `cleanup.sh` unchanged. **Only terminal Gitea evidence can confirm** socat failure class and Python fallback compatibility, full real ZITADEL client/user creation, original Login V2 browser callback/subject, negative authorization and teardown. Production TLS/MFA still separate.