- app/oidc.py is now a byte-identical copy of the canonical module (ops-docs: scripts/shared/oidc_client.py); this app's identity (logger name, session cookie, session salt) is set via oidc.configure() in main.py with the app's historical values, so existing sessions survive. tests/test_oidc_sync.py pins the copy to the canonical revision. - Guests list: the pill CONSUMES the portal-served `state` (the single invited-vs-active derivation now lives in the portal and is tested there). The local active-flag re-derivation is deleted — the shim is first-served-field-wins (state → guest_status), so the previous payload shape renders identically during a portal rollback. Guests harness extended: invited-wins-over-ledger-active, served expired, and a payload with neither field renders NO derived pill text.
56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""oidc.py sync pin — the repo copy is byte-identical to the canonical module.
|
|
|
|
WHY THIS EXISTS
|
|
app/oidc.py is a byte-identical copy of the canonical module
|
|
(co-op/ops-docs repo: scripts/shared/oidc_client.py) — the single source for
|
|
the OIDC client the thin apps ship copies of, so their login never depends
|
|
on another app being up. This test pins the copy to the canonical revision
|
|
recorded below: ANY hand edit to app/oidc.py breaks the pin and goes red.
|
|
To change the module, edit the canonical file and run
|
|
ops-docs/scripts/sync-oidc-module.sh, which re-copies and re-pins both
|
|
repos in one step (check-oidc-sync.py is the pre-deploy gate).
|
|
|
|
Generated by sync-oidc-module.sh — do not edit by hand.
|
|
|
|
Run: python3 tests/test_oidc_sync.py
|
|
"""
|
|
import hashlib
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
CANONICAL_SHA256 = "0b17a491b26bceab42fc95f1a091cee50b7ab298096e99ac7b09c771ce99cd55"
|
|
EXPECTED_CONFIGURE = '''oidc.configure("admin-panel", "admin_oidc_session", "admin-panel-oidc-session")'''
|
|
|
|
failures = []
|
|
|
|
copy = ROOT / "app" / "oidc.py"
|
|
if not copy.exists():
|
|
failures.append("app/oidc.py missing")
|
|
else:
|
|
got = hashlib.sha256(copy.read_bytes()).hexdigest()
|
|
if got == CANONICAL_SHA256:
|
|
print(f"ok - app/oidc.py matches the pinned canonical revision ({got[:16]}…)")
|
|
else:
|
|
failures.append(
|
|
"app/oidc.py DRIFTED from the pinned canonical revision\n"
|
|
f" pinned {CANONICAL_SHA256}\n"
|
|
f" actual {got}\n"
|
|
" fix: edit the canonical module (ops-docs: scripts/shared/oidc_client.py) "
|
|
"and run ops-docs/scripts/sync-oidc-module.sh — never hand-edit the copy.")
|
|
|
|
main_src = (ROOT / "app" / "main.py")
|
|
if not main_src.exists():
|
|
failures.append("app/main.py missing")
|
|
elif EXPECTED_CONFIGURE not in main_src.read_text():
|
|
failures.append(
|
|
"app/main.py does not configure this app's oidc identity:\n"
|
|
f" expected literal: {EXPECTED_CONFIGURE}")
|
|
|
|
if failures:
|
|
print()
|
|
print("FAILED: " + ", ".join(failures))
|
|
sys.exit(1)
|
|
print("oidc sync pin: OK")
|