fix: treat an unverifiable mirror as a finding, and repair auth headers

game-operating was made private on Gitea, and the check quietly skipped the mirror comparison. A repo that IS mirrored but whose far side cannot be read is unverified, and unverified must not look like fine. It is now a finding that names the missing GITEA_TOKEN.

While testing that, a second bug surfaced: the header helper built 'Authorization: token: <value>' from a name that already contained the schema, producing a silently invalid header. The Authentik check had the same defect and would have failed the moment a token was added - it never ran, so nobody would have connected the two.

Refs axion1337.chat/management#28, #31
This commit is contained in:
Thore Cimbal
2026-08-09 12:00:00 +00:00
parent f6d843672b
commit d4004ee6f4
2 changed files with 25 additions and 5 deletions
+18 -5
View File
@@ -15,6 +15,7 @@ und die ist bei uns die Alarmanlage (siehe gitops/CLAUDE.md zur TURN-Rotation).
Braucht:
GITLAB_TOKEN Lesezugriff auf die Gruppe axion1337.chat (read_api)
LAB_CA optional, Pfad zur Lab-CA-Kette
GITEA_TOKEN optional, noetig fuer private Spiegel (Lesezugriff genuegt)
AUTHENTIK_URL optional, sonst wird die Blueprint-Pruefung uebersprungen
AUTHENTIK_TOKEN
"""
@@ -39,10 +40,14 @@ uebersprungen = []
MIT_MIRROR = []
def http(url, token=None, header="PRIVATE-TOKEN"):
def http(url, token=None, header="PRIVATE-TOKEN", schema=""):
"""schema ist das Praefix VOR dem Token im Header-Wert (Gitea: "token ",
Authentik: "Bearer "). Ohne diese Trennung entsteht ein doppelter Doppelpunkt
wie "Authorization: token: abc" — der Header ist dann still ungueltig, und die
Pruefung meldet "nicht lesbar" statt eines Zugriffsfehlers."""
cmd = ["curl", "-s", "--max-time", "25"]
if token:
cmd += ["-H", f"{header}: {token}"]
cmd += ["-H", f"{header}: {schema}{token}"]
ca = os.environ.get("LAB_CA")
if ca and "git.lab" in url:
cmd += ["--cacert", ca]
@@ -103,9 +108,17 @@ def pruefe_mirror(token, gespiegelt):
if not isinstance(lab, list) or not lab:
uebersprungen.append(f"Mirror {p}: git.lab nicht lesbar")
continue
git = http(f"{GITEA}/repos/sorb/{p}/commits?limit=1")
git = http(f"{GITEA}/repos/sorb/{p}/commits?limit=1",
os.environ.get("GITEA_TOKEN"), header="Authorization", schema="token ")
if not isinstance(git, list) or not git:
uebersprungen.append(f"Mirror {p}: auf Gitea nicht lesbar")
# KEIN "uebersprungen": Dieses Repo HAT einen Mirror. Koennen wir die
# Gegenseite nicht lesen, wissen wir nicht, ob er auseinanderlaeuft —
# und "nicht geprueft" darf nicht wie "in Ordnung" aussehen. Real
# aufgefallen am 2026-08-09, als game-operating auf Gitea privat
# gestellt wurde und die Pruefung es klaglos uebersprang.
befunde.append(
f"Mirror {p}: Gegenseite auf Gitea nicht lesbar — Abgleich nicht "
f"moeglich. Bei privaten Spiegeln GITEA_TOKEN hinterlegen.")
continue
if lab[0]["id"] != git[0]["sha"]:
befunde.append(
@@ -188,7 +201,7 @@ def pruefe_authentik_blueprints():
"genau der Fall, der uns am laengsten unbemerkt lief")
return
d = http(f"{url.rstrip('/')}/api/v3/managed/blueprints/?page_size=100",
tok, header="Authorization: Bearer")
tok, header="Authorization", schema="Bearer ")
if not isinstance(d, dict):
uebersprungen.append("Authentik-Blueprints: API nicht lesbar")
return