fix(ci): pin and diagnose private OIDC forwarder readiness
This commit is contained in:
1 parent
b78270e9d4
commit
4831165548
22 files changed
+231
-27
No files matched your search
@@ -13,3 +13,8 @@ The environment is a temporary `zitplane-p05-{GITHUB_RUN_ID}` Compose stack cont
|
||||
**Privacy:** never log user password, owner PAT, OIDC client secret, Auth.js cookies, codes, nonce, state, request query or screenshots. Browser diagnostics contain only safe stage IDs. No credentials/recordings uploaded as CI artifacts. The actual CI run and individual pass/blocked status are recorded in `notes/P05-OIDC-01.md` and `docs/P05-OIDC-01.md`; source existence alone is not runtime acceptance.
|
||||
|
||||
**Phase limitations:** MFA/passkeys, production HTTPS issuer, deployment, full Admin Console human login and global SSO logout are outside this phase. Only a real successful browser callback + verified teardown is enough for its narrower user/password OIDC acceptance.
|
||||
|
||||
|
||||
## P05-OIDC-02 private forwarder remediation (pending real Gitea CI)
|
||||
|
||||
`run.sh` first verifies private Traefik on 127.0.0.1:80 responds HTTP 200 with `Host: localhost:8080`, then pulls versioned `alpine/socat:1.8.1.3`, verifies prebuilt socat entrypoint, resolves the image's immutable digest and starts by digest in the same private proxy network namespace. No `apk add` inside container and no public host binding. A bounded health probe checks the listener/socket and exact Host/issuer route; on failure it logs only stage/state/exit/HTTP status, not secrets. `provision.py` readiness probes HTTP status-only; official IAM_OWNER project/client/human APIs and Chromium login unchanged. Run #90 never tested client/user/browser flows; **next single Gitea run pending**.
|
||||
@@ -62,14 +62,26 @@ def request(method: str, path: str, token: str | None = None, payload: dict | No
|
||||
|
||||
|
||||
def wait_until_ready() -> None:
|
||||
deadline = time.monotonic() + 70
|
||||
"""HTTP 200 /debug/ready is a status probe, not a JSON API response.
|
||||
|
||||
Keep all official management/user provisioning endpoints strictly JSON.
|
||||
The runner already proves the run-owned proxy/forwarder before this point.
|
||||
"""
|
||||
deadline = time.monotonic() + 35
|
||||
probe = Request(
|
||||
ORIGIN + "/debug/ready",
|
||||
headers={"Host": "localhost:8080", "Accept": "*/*"},
|
||||
method="GET",
|
||||
)
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
request("GET", "/debug/ready")
|
||||
return
|
||||
except RuntimeError:
|
||||
time.sleep(2)
|
||||
raise RuntimeError("Disposable localhost issuer port forwarding was not ready")
|
||||
with OPENER.open(probe, timeout=6) as reply:
|
||||
if reply.status == 200:
|
||||
return
|
||||
except (HTTPError, URLError, TimeoutError, OSError):
|
||||
pass # No response body, URL, session details, or credentials logged.
|
||||
time.sleep(2)
|
||||
raise RuntimeError("Private issuer readiness HTTP 200 not established")
|
||||
|
||||
|
||||
def required_string(data: dict, name: str) -> str:
|
||||
|
||||
@@ -79,12 +79,90 @@ proxy_id="$(dc ps -q proxy)"
|
||||
test -n "$proxy_id"
|
||||
bootstrap_volume="${project}_zitadel-bootstrap"
|
||||
|
||||
# Everything below shares the private proxy network namespace (not the host).
|
||||
# Loopback-8080 preserves ZITADEL's P02 external issuer and Host routing.
|
||||
# Distinguish an unhealthy private proxy/Host route from a broken forwarder.
|
||||
# The probing container shares ONLY the disposable proxy network namespace;
|
||||
# no host-published port, credentials, response body or user HTTP query.
|
||||
docker run --rm --network "container:$proxy_id" python:3.12-alpine \
|
||||
python -c '
|
||||
import http.client, sys
|
||||
try:
|
||||
conn = http.client.HTTPConnection("127.0.0.1", 80, timeout=9)
|
||||
conn.request("GET", "/debug/ready", headers={"Host": "localhost:8080"})
|
||||
response = conn.getresponse()
|
||||
if response.status != 200:
|
||||
print("OIDC_CI_PRIVATE_PROXY_HOST_ROUTE_HTTP_STATUS=" + str(response.status), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except (OSError, http.client.HTTPException):
|
||||
print("OIDC_CI_PRIVATE_PROXY_SOCKET_OR_HTTP_BLOCKED", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print("ZITPLANE_OIDC_PRIVATE_PROXY_HOST_ROUTE_PASS")
|
||||
'
|
||||
|
||||
# Docker Hub alpine/socat has socat preinstalled, with an explicit versioned
|
||||
# published tag; no shell and no package installation during container start.
|
||||
# Resolve to a verified digest and run that IMMUTABLE digest, never latest.
|
||||
forwarder_tag="alpine/socat:1.8.1.3"
|
||||
docker pull "$forwarder_tag" >/dev/null
|
||||
entrypoint="$(docker image inspect --format '{{json .Config.Entrypoint}}' "$forwarder_tag")"
|
||||
if [ "$entrypoint" != '["socat"]' ]; then
|
||||
echo OIDC_CI_FORWARDER_PREBUILT_ENTRYPOINT_NOT_VERIFIED >&2
|
||||
exit 1
|
||||
fi
|
||||
forwarder_image="$(docker image inspect --format '{{index .RepoDigests 0}}' "$forwarder_tag")"
|
||||
case "$forwarder_image" in
|
||||
alpine/socat@sha256:*) echo ZITPLANE_OIDC_PINNED_FORWARDER_DIGEST_VERIFIED_PASS ;;
|
||||
*) echo OIDC_CI_FORWARDER_IMAGE_DIGEST_MISSING >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
# NetNS-local listener 127.0.0.1:8080 -> netNS-local Traefik 127.0.0.1:80.
|
||||
# The original P02 external issuer remains exactly http://localhost:8080.
|
||||
docker run -d --name "$forwarder" \
|
||||
--label "zitplane.oidc.run=$GITHUB_RUN_ID" \
|
||||
--network "container:$proxy_id" alpine:3.21 \
|
||||
sh -ec 'apk add --no-cache socat >/dev/null 2>&1; exec socat TCP-LISTEN:8080,bind=127.0.0.1,reuseaddr,fork TCP:127.0.0.1:80' >/dev/null
|
||||
--network "container:$proxy_id" "$forwarder_image" \
|
||||
TCP-LISTEN:8080,bind=127.0.0.1,reuseaddr,fork TCP:127.0.0.1:80 >/dev/null
|
||||
|
||||
# Bounded socket+exact Host HTTP probe. Container existence is NOT readiness.
|
||||
ready=0
|
||||
attempt=0
|
||||
while [ "$attempt" -lt 12 ]; do
|
||||
attempt=$((attempt + 1))
|
||||
state="$(docker inspect -f '{{.State.Status}}' "$forwarder")"
|
||||
if [ "$state" != running ]; then
|
||||
exitcode="$(docker inspect -f '{{.State.ExitCode}}' "$forwarder")"
|
||||
echo "OIDC_CI_FORWARDER_NOT_RUNNING_STATE=$state EXIT_CODE=$exitcode" >&2
|
||||
exit 1
|
||||
fi
|
||||
if docker run --rm --network "container:$proxy_id" python:3.12-alpine \
|
||||
python -c '
|
||||
import http.client
|
||||
conn = http.client.HTTPConnection("127.0.0.1", 8080, timeout=5)
|
||||
conn.request("GET", "/debug/ready", headers={"Host": "localhost:8080"})
|
||||
assert conn.getresponse().status == 200
|
||||
' >/dev/null 2>&1; then
|
||||
ready=1
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
if [ "$ready" -ne 1 ]; then
|
||||
state="$(docker inspect -f '{{.State.Status}}' "$forwarder")"
|
||||
exitcode="$(docker inspect -f '{{.State.ExitCode}}' "$forwarder")"
|
||||
echo "OIDC_CI_FORWARDER_HTTP_NOT_READY_STATE=$state EXIT_CODE=$exitcode" >&2
|
||||
# One redacted diagnostic: print only an HTTP status or a fixed socket marker.
|
||||
docker run --rm --network "container:$proxy_id" python:3.12-alpine \
|
||||
python -c '
|
||||
import http.client, sys
|
||||
try:
|
||||
conn = http.client.HTTPConnection("127.0.0.1", 8080, timeout=5)
|
||||
conn.request("GET", "/debug/ready", headers={"Host": "localhost:8080"})
|
||||
print("OIDC_CI_FORWARDER_HTTP_STATUS=" + str(conn.getresponse().status), file=sys.stderr)
|
||||
except (OSError, http.client.HTTPException):
|
||||
print("OIDC_CI_FORWARDER_LISTENER_CONNECTION_BLOCKED", file=sys.stderr)
|
||||
' || true
|
||||
exit 1
|
||||
fi
|
||||
echo ZITPLANE_OIDC_PRIVATE_LOOPBACK_FORWARDER_READY_PASS
|
||||
|
||||
docker volume create --name "$secret_volume" \
|
||||
--label "zitplane.oidc.run=$GITHUB_RUN_ID" >/dev/null
|
||||
|
||||
|
||||
Reference in new issue
Block a user