M8-T1/T2 umgesetzt: Keycloak idempotent via Ansible + oauth2-proxy auf CT 103 live
- keycloak_realm_config: KC auf 10.0.0.4:8080 (nicht loopback), Mapper auf
realm-weiten roles-Scope (KC26: clients/{id}/client-scopes ist 404),
attributes-Drift nur eigene Keys; site.yml idempotent changed=0; verifiziert:
Rolle gnai-research-user, Client gnai-research (confidential, redirect/origins),
groups-Claim-Mapper, ghost-Role-Mapping
- reverse_proxy_oauth2proxy: digest-gepinnt v7.15.5 (sha256:0d989b27...),
Environment mit Leerzeichen gequotet, cookie-secret base64(24B)=32 chars,
is-active rc=4 tolerieren; live verifiziert: ping 200, /oauth2/auth 401 ohne
Session, LAN geblockt, /oauth2/start 302 zu Keycloak scope=openid+email+profile+groups
- gnai-research client-secret als Podman-Secret auf CT 103 (via Bootstrap-Token aus API)
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -120,7 +120,7 @@ Internet → NPM (CT 103, 443) → auth_request-Subrequest an oauth2-proxy
|
||||
10. E2E: Research-Auftrag in GPT Researcher läuft gegen llama.cpp +
|
||||
SearXNG, Report mit Quellen; NPM-Timeouts für lange Läufe gesetzt.
|
||||
|
||||
## 5. Arbeitspakete (Umsetzung ab 14.11.2026)
|
||||
## 5. Arbeitspakete (Stand 17.11.2026: M8-T1 und M8-T2 umgesetzt und verifiziert)
|
||||
|
||||
| # | Paket | Ziel | Wo |
|
||||
| --- | --- | --- | --- |
|
||||
@@ -140,3 +140,26 @@ Internet → NPM (CT 103, 443) → auth_request-Subrequest an oauth2-proxy
|
||||
exklusiv — gleicher Host, Wartungsfenster beachten).
|
||||
- Ob DeerFlow später als dritter Harness mit Sandboxes ergänzt wird
|
||||
(Community-Favorit), hängt von den Erfahrungen mit GPT Researcher ab.
|
||||
|
||||
## 7. Belegter Stand 17.11.2026
|
||||
|
||||
- **M8-T1 (Keycloak, idempotent via Ansible):** Rolle `keycloak_realm_config` im
|
||||
CT-102-Projekt; `site.yml` ok=103 changed=0 (idempotent). Verifiziert per
|
||||
Admin-API: Realm-Rolle `gnai-research-user`, Client `gnai-research`
|
||||
(confidential, standard flow only, direct grants OFF, redirect
|
||||
`https://research.ghostnet.selfhost.eu/oauth2/callback`, web origin gesetzt),
|
||||
Mapper `realm-roles-to-groups` auf dem realm-weiten `roles`-Scope
|
||||
(KC26: `/clients/{id}/client-scopes` ist 404 — Mapper liegt auf `roles`),
|
||||
Claim `groups` in ID/access token + userinfo; `ghost` hat die Rolle.
|
||||
Befunde: Keycloak hört auf `10.0.0.4:8080` (nicht loopback); Client-`attributes`
|
||||
enthalten KC-Defaults (Drift-Vergleich nur eigene Keys).
|
||||
- **M8-T2 (oauth2-proxy auf CT 103):** Rolle `reverse_proxy_oauth2proxy`,
|
||||
Image `quay.io/oauth2-proxy/oauth2-proxy@sha256:0d989b27…` (v7.15.5),
|
||||
`site.yml` idempotent changed=0. Verifiziert: `/ping` 200 auf 127.0.0.1:4180,
|
||||
`/oauth2/auth` ohne Session 401, LAN 10.0.0.10:4180 geblockt (000),
|
||||
`/oauth2/start` → 302 zu Keycloak mit `client_id=gnai-research`,
|
||||
`scope=openid+email+profile+groups`. Befunde: Quadlet-`Environment` mit
|
||||
Leerzeichen braucht Quotes; cookie-secret als base64(24B)=32 Zeichen
|
||||
(v7.15 prüft Stringlänge); `systemctl is-active` rc=4 wenn Unit noch nicht
|
||||
geladen. Client-Secret als Podman-Secret `oauth2-proxy-client-secret`
|
||||
(aus Keycloak-API via Bootstrap-Token gelesen, nie in Logs/Git).
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# manage-users, view-users. Copy the secret to CT 102:
|
||||
# install -m 0600 /dev/null /etc/keycloak-ansible/client_secret (als root)
|
||||
# und Secret eintragen.
|
||||
keycloak_realm_internal_url: http://127.0.0.1:8080
|
||||
keycloak_realm_internal_url: http://10.0.0.4:8080 # Keycloak listens on the CT IP, not loopback (conmon, 10.0.0.4:8080)
|
||||
keycloak_realm_name: Ghost.net
|
||||
keycloak_realm_bootstrap_client_id: ansible-keycloak-admin
|
||||
keycloak_realm_ansible_secret_file: /etc/keycloak-ansible/client_secret
|
||||
|
||||
+19
-6
@@ -96,8 +96,18 @@ st, current = req("GET", f"{R}/clients/{cuuid}")
|
||||
assert st == 200
|
||||
drift = False
|
||||
for k, v in client_body.items():
|
||||
if k == "attributes":
|
||||
# Keycloak stores many default attributes; only compare our own key
|
||||
cur_attrs = current.get("attributes") or {}
|
||||
for ak, av in v.items():
|
||||
if cur_attrs.get(ak) != av:
|
||||
drift = True
|
||||
print(f"DRIFT attributes.{ak}: current={cur_attrs.get(ak)!r} wanted={av!r}", file=sys.stderr)
|
||||
break
|
||||
continue
|
||||
if current.get(k) != v:
|
||||
drift = True
|
||||
print(f"DRIFT {k}: current={current.get(k)!r} wanted={v!r}", file=sys.stderr)
|
||||
break
|
||||
if drift:
|
||||
merged = dict(current)
|
||||
@@ -106,12 +116,15 @@ if drift:
|
||||
assert st == 204, f"update client failed: {st}"
|
||||
changed = True
|
||||
|
||||
# --- 3) dedicated client scope + realm-role -> groups claim mapper ---
|
||||
st, scopes = req("GET", f"{R}/clients/{cuuid}/client-scopes")
|
||||
assert st == 200
|
||||
dedicated = [s for s in scopes if s.get("name") == f"{c['clientId']}-dedicated"]
|
||||
assert dedicated, "dedicated client scope missing after client create"
|
||||
scope_id = dedicated[0]["id"]
|
||||
# --- 3) realm-role -> groups claim mapper on the realm-wide "roles" scope ---
|
||||
# KC26: /clients/{id}/client-scopes is gone (404) and dedicated scopes are not
|
||||
# listed globally; the "roles" scope is a default client scope of every new
|
||||
# client, so the mapper lands there and every such client gets the groups claim.
|
||||
st, scopes = req("GET", f"{R}/client-scopes")
|
||||
assert st == 200, f"client-scopes lookup failed: {st}"
|
||||
roles_scope = [s for s in scopes if s.get("name") == "roles"]
|
||||
assert roles_scope, "realm-wide 'roles' client scope missing"
|
||||
scope_id = roles_scope[0]["id"]
|
||||
m = spec["research_mapper"]
|
||||
mapper_body = {
|
||||
"name": m["name"],
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
# podman image inspect ... --format '{{.Digest}}'
|
||||
reverse_proxy_oauth2proxy_image: quay.io/oauth2-proxy/oauth2-proxy
|
||||
reverse_proxy_oauth2proxy_image_tag: v7.15.5
|
||||
reverse_proxy_oauth2proxy_image_ref: "{{ reverse_proxy_oauth2proxy_image }}@sha256:REPLACE_WITH_PINNED_DIGEST"
|
||||
reverse_proxy_oauth2proxy_image_ref: "{{ reverse_proxy_oauth2proxy_image }}@sha256:0d989b27d90d5e527fb2b045d864c4001c3104bdd763b3211b7e9ba2110380ea" # v7.15.5, digest verifiziert 2026-11-17
|
||||
|
||||
reverse_proxy_oauth2proxy_container_name: oauth2-proxy
|
||||
reverse_proxy_oauth2proxy_service_name: oauth2-proxy.service
|
||||
|
||||
+5
-2
@@ -20,7 +20,9 @@
|
||||
- name: Create the cookie secret (random 32 bytes, host-local only)
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
head -c 32 /dev/urandom | base64 | podman secret create {{ reverse_proxy_oauth2proxy_cookie_secret_name }} -
|
||||
# base64 of 24 raw bytes = exactly 32 chars: v7.15 validates the string
|
||||
# length ("must be 16, 24, or 32 bytes"); 32 raw or 44-char base64 fail
|
||||
head -c 24 /dev/urandom | base64 -w0 | podman secret create {{ reverse_proxy_oauth2proxy_cookie_secret_name }} -
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when: oauth2proxy_cookie_secret_exists.rc == 1
|
||||
@@ -73,7 +75,8 @@
|
||||
argv: [systemctl, is-active, "{{ reverse_proxy_oauth2proxy_service_name }}"]
|
||||
register: oauth2proxy_unit_state
|
||||
changed_when: false
|
||||
failed_when: oauth2proxy_unit_state.rc not in [0, 3]
|
||||
# rc 3 = inactive, rc 4 = unit not loaded yet (check mode skips daemon-reload)
|
||||
failed_when: oauth2proxy_unit_state.rc not in [0, 3, 4]
|
||||
check_mode: false
|
||||
|
||||
- name: Start the oauth2-proxy unit
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ Environment=OAUTH2_PROXY_PROVIDER={{ reverse_proxy_oauth2proxy_provider }}
|
||||
Environment=OAUTH2_PROXY_OIDC_ISSUER_URL={{ reverse_proxy_oauth2proxy_oidc_issuer_url }}
|
||||
Environment=OAUTH2_PROXY_CLIENT_ID={{ reverse_proxy_oauth2proxy_client_id }}
|
||||
Environment=OAUTH2_PROXY_REDIRECT_URL={{ reverse_proxy_oauth2proxy_redirect_url }}
|
||||
Environment=OAUTH2_PROXY_SCOPE={{ reverse_proxy_oauth2proxy_scopes }}
|
||||
Environment="OAUTH2_PROXY_SCOPE={{ reverse_proxy_oauth2proxy_scopes }}"
|
||||
Environment=OAUTH2_PROXY_HTTP_ADDRESS={{ reverse_proxy_oauth2proxy_http_address }}
|
||||
Environment=OAUTH2_PROXY_METRICS_ADDRESS={{ reverse_proxy_oauth2proxy_metrics_address }}
|
||||
# upstream is never used directly; nginx auth_request only asks /oauth2/auth
|
||||
@@ -39,7 +39,7 @@ Environment=OAUTH2_PROXY_EMAIL_DOMAINS={{ reverse_proxy_oauth2proxy_email_domain
|
||||
Environment=OAUTH2_PROXY_WHITELIST_DOMAIN={{ reverse_proxy_oauth2proxy_whitelist_domain }}
|
||||
Environment=OAUTH2_PROXY_ALLOWED_GROUP={{ reverse_proxy_oauth2proxy_allowed_group }}
|
||||
Environment=OAUTH2_PROXY_OIDC_GROUPS_CLAIM={{ reverse_proxy_oauth2proxy_oidc_groups_claim }}
|
||||
Environment=OAUTH2_PROXY_SKIP_AUTH_REGEX={{ reverse_proxy_oauth2proxy_skip_auth_regex }}
|
||||
Environment="OAUTH2_PROXY_SKIP_AUTH_REGEX={{ reverse_proxy_oauth2proxy_skip_auth_regex }}"
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
|
||||
Reference in New Issue
Block a user