coulomb-social/scripts/keycape-client-repair.py
tegwick ac7bac1852
Some checks failed
Use-case regression gate / usecase-regressions (push) Has been cancelled
Prepare persistent personal app release and guarded OIDC repair
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a10e2d-a5ef-7e92-b03d-b1694e915680
2026-10-06 15:14:38 +02:00

47 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Restore the historical public client through NetKingdom's guarded lane.
Inspection is read-only. Apply requires exact founder approval and a fresh
UID/resource-version receipt. Secret values stay inside the owner helper.
"""
import importlib.util
import os
from pathlib import Path
from types import SimpleNamespace
def load(name, path):
spec = importlib.util.spec_from_file_location(name, path)
result = importlib.util.module_from_spec(spec)
spec.loader.exec_module(result)
return result
def configure(owner_root):
rollout = load("keycape_guarded_rollout", owner_root / "portal-client-rollout.py")
historical = load("coulomb_registration", owner_root / "register-coulomb-social.py")
original = rollout.replacement
rollout.portal = SimpleNamespace(CLIENT_ID=historical.CLIENT_ID, CLIENT=historical.CLIENT)
def replacement(secret):
_, config, _ = rollout.pin.issuer_document(secret)
for client in config.get("clients", []):
if client.get("clientId") == historical.CLIENT_ID:
rollout.require(client == historical.CLIENT, "existing_registration_differs")
return original(secret)
rollout.replacement = replacement
return rollout
if __name__ == "__main__":
try:
owner_root = Path(os.environ.get(
"NET_KINGDOM_KEYCAPE_DIR",
str(Path.home() / "net-kingdom/sso-mfa/k8s/keycape"),
))
helper = configure(owner_root)
except Exception:
print('{"status":"failed","reason":"owner_helper_unavailable"}')
raise SystemExit(1)
raise SystemExit(helper.main())