ci(oidc): build isolated imported Login image and reuse real browser acceptance
This commit is contained in:
1 parent
c93468fb60
commit
fcfa59e826
7 files changed
+210
No files matched your search
@@ -0,0 +1,49 @@
|
|||||||
|
name: ZitPlane P05-OIDC-06 Imported Login V2 Disposable Image Acceptance
|
||||||
|
|
||||||
|
# Manual-only, isolated runner. No registry publishing or production access.
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
custom_login:
|
||||||
|
name: Build imported Login image and verify real OIDC with owned cleanup
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: node:22-alpine
|
||||||
|
timeout-minutes: 70
|
||||||
|
steps:
|
||||||
|
- name: Install Git and Docker Compose CLI before checkout
|
||||||
|
run: apk add --no-cache git docker-cli docker-cli-compose python3
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
github-server-url: https://dev.ivib.cc
|
||||||
|
- name: Frozen imported Login V2 build and local disposable image
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
sh tests/ci/login_image/build.sh
|
||||||
|
- name: Real Chromium OIDC through custom Login image
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
export ZITPLANE_OIDC_CUSTOM_LOGIN_CI=1
|
||||||
|
export ZITPLANE_OIDC_CUSTOM_LOGIN_IMAGE="zitplane-login-ci:$GITHUB_RUN_ID"
|
||||||
|
sh tests/ci/oidc_e2e/run.sh
|
||||||
|
- name: Always clean run-owned OIDC state and custom image builder
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
set +e
|
||||||
|
rc=0
|
||||||
|
if [ -f tests/ci/oidc_e2e/cleanup.sh ]; then
|
||||||
|
sh tests/ci/oidc_e2e/cleanup.sh || rc=1
|
||||||
|
else
|
||||||
|
echo OIDC_CI_CLEANUP_SCRIPT_MISSING >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
if [ -f tests/ci/login_image/cleanup.sh ]; then
|
||||||
|
sh tests/ci/login_image/cleanup.sh || rc=1
|
||||||
|
else
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_CLEANUP_SCRIPT_MISSING >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
exit "$rc"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# P05-OIDC-06 CI-only overlay. Applied ONLY by run.sh explicit opt-in.
|
||||||
|
# It swaps ONLY the disposable Login image; no TLS/auth/ports/routes.
|
||||||
|
services:
|
||||||
|
zitadel-login:
|
||||||
|
image: ${ZITPLANE_OIDC_CUSTOM_LOGIN_IMAGE:?Missing run-owned local Login image}
|
||||||
|
pull_policy: never
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# tests/ci/login_image/ manifest
|
||||||
|
|
||||||
|
| File | Purpose | Phase |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [README.md](README.md) | Scope/ownership/privacy and manual CI usage | P05-OIDC-06 |
|
||||||
|
| [MINIFEST.md](MINIFEST.md) | Exact direct file register | P05-OIDC-06 |
|
||||||
|
| [build.sh](build.sh) | Disposable frozen imported build + local image packaging | P05-OIDC-06 |
|
||||||
|
| [cleanup.sh](cleanup.sh) | Always-run exact-labeled builder/image/temp context teardown | P05-OIDC-06 |
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# CI-only imported Login image acceptance helpers
|
||||||
|
|
||||||
|
This directory is used solely by the manual Gitea P05-OIDC-06 workflow. It builds the original imported Login V2 workspace **inside a run-labeled disposable Node 22 Debian builder** and packages only its generated Next standalone output with the **unchanged upstream Login Dockerfile** into a local Docker image.
|
||||||
|
|
||||||
|
- `build.sh`: refuse preexisting state, run frozen pinned pnpm/Nx build, create local run-tagged image. No registry push, no production data, no host ports.
|
||||||
|
- `cleanup.sh`: used by the workflow `always()` step, **after** the existing OIDC cleanup; verify labels and remove only this run's builder/image/temp build context.
|
||||||
|
- The existing real browser acceptance harness remains the security authority; custom-image mode is explicit opt-in and uses separate Compose overlay.
|
||||||
|
|
||||||
|
Update these helpers only in a separately approved source scope; maintain MINIFEST.md and never copy upstream source edits, credentials or CI output to Git.
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Imported source is compiled entirely inside a run-owned Docker builder.
|
||||||
|
# Only .next/standalone and the untouched upstream Dockerfile enter the
|
||||||
|
# temporary local image build context. No source tree write or registry push.
|
||||||
|
set -eu
|
||||||
|
: "${GITHUB_RUN_ID:?Missing numeric disposable Gitea run ID}"
|
||||||
|
case "$GITHUB_RUN_ID" in *[!0-9]*|'') echo LOGIN_CI_INVALID_RUN_ID >&2; exit 1;; esac
|
||||||
|
builder="zitplane-login-$GITHUB_RUN_ID-builder"
|
||||||
|
image="zitplane-login-ci:$GITHUB_RUN_ID"
|
||||||
|
context="/tmp/zitplane-login-build-$GITHUB_RUN_ID"
|
||||||
|
label="zitplane.login.run=$GITHUB_RUN_ID"
|
||||||
|
docker info --format '{{.Driver}}' >/dev/null
|
||||||
|
if docker container inspect "$builder" >/dev/null 2>&1 ||
|
||||||
|
docker image inspect "$image" >/dev/null 2>&1 ||
|
||||||
|
[ -e "$context" ] ||
|
||||||
|
[ -e auth/ui/v2/apps/login/.env ] ||
|
||||||
|
[ -e auth/ui/v2/apps/login/.env.prod ]; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_PREEXISTING_STATE_REFUSED >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
test -r auth/ui/v2/apps/login/Dockerfile
|
||||||
|
test -r auth/ui/v2/pnpm-lock.yaml
|
||||||
|
test -r tests/ci/oidc_e2e/cleanup.sh
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_ISOLATED_BUILD_PREFLIGHT_PASS
|
||||||
|
docker create --name "$builder" --label "$label" node:22-bookworm sleep 3600 >/dev/null
|
||||||
|
docker start "$builder" >/dev/null
|
||||||
|
docker exec "$builder" mkdir -p /work
|
||||||
|
docker cp auth/ui/v2 "$builder:/work/v2"
|
||||||
|
docker exec -w /work/v2 "$builder" sh -ec '
|
||||||
|
corepack enable
|
||||||
|
corepack prepare pnpm@10.30.3 --activate
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_FROZEN_INSTALL_PASS
|
||||||
|
: > apps/login/.env
|
||||||
|
export NEXT_PUBLIC_BASE_PATH=/ui/v2/login
|
||||||
|
export NX_NO_CLOUD=true NX_DAEMON=false CI=true
|
||||||
|
pnpm exec nx run @zitadel/login:build --skip-nx-cache
|
||||||
|
rm -f apps/login/.env
|
||||||
|
test -f apps/login/.next/standalone/apps/login/server.js
|
||||||
|
test -f apps/login/.next/standalone/entrypoint.sh
|
||||||
|
test -f apps/login/.next/standalone/healthcheck.mjs
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_STANDALONE_BUILD_PASS
|
||||||
|
'
|
||||||
|
mkdir -m 700 -p "$context/.next"
|
||||||
|
touch "$context/.zitplane-owned-$GITHUB_RUN_ID"
|
||||||
|
docker cp "$builder:/work/v2/apps/login/.next/standalone" "$context/.next/standalone"
|
||||||
|
cp auth/ui/v2/apps/login/Dockerfile "$context/Dockerfile"
|
||||||
|
docker build --pull --label "$label" -t "$image" -f "$context/Dockerfile" "$context"
|
||||||
|
actual_label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$image")"
|
||||||
|
image_id="$(docker image inspect --format '{{.Id}}' "$image")"
|
||||||
|
if [ "$actual_label" != "$GITHUB_RUN_ID" ]; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_IMAGE_OWNERSHIP_MISMATCH >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
case "$image_id" in sha256:*) ;; *) echo ZITPLANE_CUSTOM_LOGIN_IMAGE_ID_MISSING >&2; exit 1;; esac
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_LOCAL_IMAGE_BUILT_PASS
|
||||||
|
# Record only a digest/ID and sanitized ownership metadata (never credentials).
|
||||||
|
echo "ZITPLANE_CUSTOM_LOGIN_IMAGE_ID=$image_id"
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Idempotent always() teardown for ONLY this workflow's builder/image/context.
|
||||||
|
# The previous OIDC owned cleanup MUST run before removing the image.
|
||||||
|
set -eu
|
||||||
|
: "${GITHUB_RUN_ID:?Missing run ID}"
|
||||||
|
case "$GITHUB_RUN_ID" in *[!0-9]*|'') echo LOGIN_CI_CLEANUP_INVALID_RUN_ID >&2; exit 1;; esac
|
||||||
|
builder="zitplane-login-$GITHUB_RUN_ID-builder"
|
||||||
|
image="zitplane-login-ci:$GITHUB_RUN_ID"
|
||||||
|
context="/tmp/zitplane-login-build-$GITHUB_RUN_ID"
|
||||||
|
rc=0
|
||||||
|
if docker container inspect "$builder" >/dev/null 2>&1; then
|
||||||
|
label="$(docker inspect -f '{{ index .Config.Labels "zitplane.login.run" }}' "$builder" 2>/dev/null || true)"
|
||||||
|
if [ "$label" != "$GITHUB_RUN_ID" ]; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_BUILDER_REFUSED >&2
|
||||||
|
rc=1
|
||||||
|
elif ! docker rm -f "$builder" >/dev/null; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_BUILDER_CLEANUP_FAILED >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if docker image inspect "$image" >/dev/null 2>&1; then
|
||||||
|
label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$image" 2>/dev/null || true)"
|
||||||
|
if [ "$label" != "$GITHUB_RUN_ID" ]; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_IMAGE_REFUSED >&2
|
||||||
|
rc=1
|
||||||
|
elif ! docker image rm "$image" >/dev/null; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_LOCAL_IMAGE_CLEANUP_FAILED >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -e "$context" ]; then
|
||||||
|
if [ -f "$context/.zitplane-owned-$GITHUB_RUN_ID" ]; then
|
||||||
|
rm -rf "$context"
|
||||||
|
else
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_UNOWNED_CONTEXT_REFUSED >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if docker container inspect "$builder" >/dev/null 2>&1 ||
|
||||||
|
docker image inspect "$image" >/dev/null 2>&1 ||
|
||||||
|
[ -e "$context" ]; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_RESOURCES_LEFTOVER >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
if [ "$rc" -ne 0 ]; then
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_CLEANUP_FAILED >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_ALL_BUILD_RESOURCES_CLEANED_PASS
|
||||||
@@ -9,12 +9,33 @@ secret_volume="zitplane-oidc-$GITHUB_RUN_ID-secrets"
|
|||||||
browser="zitplane-oidc-$GITHUB_RUN_ID-browser"
|
browser="zitplane-oidc-$GITHUB_RUN_ID-browser"
|
||||||
forwarder="zitplane-oidc-$GITHUB_RUN_ID-loopback"
|
forwarder="zitplane-oidc-$GITHUB_RUN_ID-loopback"
|
||||||
marker=".p05-oidc-owned"
|
marker=".p05-oidc-owned"
|
||||||
|
# Only the new manual custom Login workflow may enable this extra Compose file.
|
||||||
|
# Default mode uses the EXACT original three-file Compose invocation.
|
||||||
|
custom_login=0
|
||||||
|
case "${ZITPLANE_OIDC_CUSTOM_LOGIN_CI:-}" in
|
||||||
|
"") ;;
|
||||||
|
1) custom_login=1 ;;
|
||||||
|
*) echo OIDC_CI_CUSTOM_LOGIN_MODE_INVALID >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
custom_image="zitplane-login-ci:$GITHUB_RUN_ID"
|
||||||
|
if [ "$custom_login" -eq 1 ] && [ "${ZITPLANE_OIDC_CUSTOM_LOGIN_IMAGE:-}" != "$custom_image" ]; then
|
||||||
|
echo OIDC_CI_CUSTOM_LOGIN_IMAGE_NOT_RUN_OWNED >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
dc() {
|
dc() {
|
||||||
|
if [ "$custom_login" -eq 1 ]; then
|
||||||
|
docker compose --env-file .env -p "$project" \
|
||||||
|
-f deployment/docker/compose.backend.dev.yaml \
|
||||||
|
-f tests/ci/compose.portless.override.yaml \
|
||||||
|
-f tests/ci/oidc_e2e/compose.owner.override.yaml \
|
||||||
|
-f deployment/docker/compose.login-ci.override.yaml "$@"
|
||||||
|
else
|
||||||
docker compose --env-file .env -p "$project" \
|
docker compose --env-file .env -p "$project" \
|
||||||
-f deployment/docker/compose.backend.dev.yaml \
|
-f deployment/docker/compose.backend.dev.yaml \
|
||||||
-f tests/ci/compose.portless.override.yaml \
|
-f tests/ci/compose.portless.override.yaml \
|
||||||
-f tests/ci/oidc_e2e/compose.owner.override.yaml "$@"
|
-f tests/ci/oidc_e2e/compose.owner.override.yaml "$@"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
docker --version
|
docker --version
|
||||||
@@ -74,6 +95,16 @@ for name in postgres zitadel-api zitadel-login proxy; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo ZITPLANE_OIDC_FOUR_SERVICES_READY_PASS
|
echo ZITPLANE_OIDC_FOUR_SERVICES_READY_PASS
|
||||||
|
if [ "$custom_login" -eq 1 ]; then
|
||||||
|
expected_id="$(docker image inspect --format '{{.Id}}' "$custom_image")"
|
||||||
|
expected_label="$(docker image inspect --format '{{ index .Config.Labels "zitplane.login.run" }}' "$custom_image")"
|
||||||
|
actual_id="$(docker inspect --format '{{.Image}}' "$(dc ps -q zitadel-login)")"
|
||||||
|
[ "$expected_label" = "$GITHUB_RUN_ID" ] && [ "$actual_id" = "$expected_id" ] || {
|
||||||
|
echo OIDC_CI_CUSTOM_LOGIN_RUNTIME_PROVENANCE_FAILED >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo ZITPLANE_CUSTOM_LOGIN_RUNNING_IMAGE_MATCH_PASS
|
||||||
|
fi
|
||||||
|
|
||||||
proxy_id="$(dc ps -q proxy)"
|
proxy_id="$(dc ps -q proxy)"
|
||||||
test -n "$proxy_id"
|
test -n "$proxy_id"
|
||||||
|
|||||||
Reference in new issue
Block a user