M8-T1 idempotent: neue Rolle keycloak_realm_config (Admin-REST-API via Service Account)

- Bootstrap einmalig per UI: Client ansible-keycloak-admin (confidential,
  service account, realm-management manage-*), Secret als 0600-Datei auf CT 102
- danach site.yml synct idempotent: Realm-Rolle gnai-research-user, Client
  gnai-research (redirect/web-origins, standard flow only), groups-Claim-Mapper
  (oidc-usermodel-realm-role-mapper auf Claim groups), Role-Mapping ghost
- files/keycloak_realm_sync.py (stdlib only) treibt /admin/realms/Ghost.net per
  GET->POST/PUT, Ausgabe CHANGED/UNCHANGED; Spec in defaults/main.yml
- GNAI-023 M8-T1 umgestellt auf Bootstrap + Playbook; syntax-check OK

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-17 07:17:27 +01:00
parent 521ec5cdf3
commit f84ed85673
7 changed files with 293 additions and 1 deletions
@@ -124,7 +124,7 @@ Internet → NPM (CT 103, 443) → auth_request-Subrequest an oauth2-proxy
| # | Paket | Ziel | Wo |
| --- | --- | --- | --- |
| M8-T1 | Keycloak-Client `gnai-research` + Realm-Rolle + Claim-Mapper; Secret als Podman-Secret. **Detaillierte Betreiberschritte (Keycloak 26.2.4, Admin-UI `https://auth.ghostnet.selfhost.eu`, oben links Realm-Dropdown = `Ghost.net`):** **A) Realm-Rolle:** Menü „Realm roles" → „Create role" → Name `gnai-research-user` → Save. **B) Client:** Menü „Clients" → „Create client": Client ID `gnai-research`, Name „Ghostnet Research (oauth2-proxy)" → Next; Capability config: **Client authentication ON** (confidential), Authorization OFF, Standard flow ON, Direct access grants / Implicit / Service accounts / Device / CIBA **OFF** → Next; Login settings: Root URL `https://research.ghostnet.selfhost.eu`, Valid redirect URIs `https://research.ghostnet.selfhost.eu/oauth2/callback`, Valid post logout redirect URIs `https://research.ghostnet.selfhost.eu/*`, Web origins `https://research.ghostnet.selfhost.eu` → Save. **C) groups-Claim-Mapper** (damit `--oidc-groups-claim=groups` greift): Clients → `gnai-research` → „Client scopes" → `gnai-research-dedicated` → „Mappers" → „Add mapper" → „By configuration" → „User Realm Role": Mapper name `realm-roles-to-groups`, Multivalued ON, **Token Claim Name `groups`**, Claim JSON Type String, Add to ID token ON, Add to access token ON, Add to userinfo ON → Save. **D) Secret auf CT 103:** `ssh ansible-deploy@10.0.0.10` → `podman secret rm oauth2-proxy-client-secret 2>/dev/null; printf '%s' '<client-secret-aus-Credentials-Tab>' | podman secret create oauth2-proxy-client-secret -` (Secret nie in Chat/Repo). **E) Rolle zuweisen:** Users → `ghost` → „Role mapping" → „Assign role" → `gnai-research-user` → Assign. **F) Nach dem Deploy testen:** `curl -sI https://research.ghostnet.selfhost.eu/` → 302 zu `auth.ghostnet.selfhost.eu/.../login`. Hinweis: Redirect-URI jetzt schon registrieren, auch wenn `research.ghostnet.selfhost.eu` per DNS/vHost erst in M8-T3 live wird. | CT 102 (Admin-UI) + CT 103 (Secret) | Keycloak |
| M8-T1 | Keycloak-Objekte **idempotent per Ansible** (Rolle `keycloak_realm_config` im CT-102-Projekt, Admin-REST-API via Service Account). **Einmaliger Bootstrap (Operator, Admin-UI `https://auth.ghostnet.selfhost.eu`, Realm-Dropdown = `Ghost.net`):** Clients → Create client: ID `ansible-keycloak-admin`, publicClient OFF, **Service accounts roles ON**, Standard flow OFF; Service account roles → `realm-management`: `manage-realm`, `manage-clients`, `manage-users`, `view-users`; Credentials → Secret kopieren; auf CT 102: `install -d -m 0700 /etc/keycloak-ansible && install -m 0600 /dev/null /etc/keycloak-ansible/client_secret` und Secret eintragen (nie in Git/Chat). **Danach alles per Playbook:** `cd proxmox/lxc/ct-102-keycloak/ansible && ansible-playbook -i inventories/production playbooks/site.yml` — synct Realm-Rolle `gnai-research-user`, Client `gnai-research` (confidential, Standard flow only, Redirect `https://research.ghostnet.selfhost.eu/oauth2/callback`, Web Origin `https://research.ghostnet.selfhost.eu`, post-logout `https://research.ghostnet.selfhost.eu/*`), Mapper `realm-roles-to-groups` (dedicated scope, Claim `groups`, in ID/access token + userinfo) und Role-Mapping für `ghost`; zweiter Lauf `changed=0`. Spec in `roles/keycloak_realm_config/defaults/main.yml`, Doku im Rollen-README. **Test nach M8-T3:** `curl -sI https://research.ghostnet.selfhost.eu/` → 302 zu `auth.ghostnet.selfhost.eu/...login...client_id=gnai-research`. | CT 102 (Bootstrap einmalig UI + Secret-Datei, danach site.yml) | Keycloak |
| M8-T2 | oauth2-proxy v7.15.5 (quay.io, digest-gepinnt) als Quadlet auf CT 103 in eigenem Podman-Netz mit NPM, **kein** publish; Env: provider `oidc`, issuer, client-id/secret + cookie-secret als Podman-Secrets, `--email-domain`, `--whitelist-domain=.ghostnet.selfhost.eu`, `--allowed-group=gnai-research-user`, `--oidc-groups-claim=groups`, `--skip-auth-regex=^/ping$`, `--reverse-proxy=true`, `--set-xauthrequest` | CT 103, Rolle im CT-103-Ansible-Projekt | IAP |
| M8-T3 | NPM-vHost `research.ghostnet.selfhost.eu` (LE-TLS, Force SSL) mit Advanced-Snippet `auth_request /oauth2/auth` + interne `location /oauth2/`; Split-DNS-Record auf CT 100; NPM-API via CT-103-Ansible | CT 103 + CT 100 | Ingress |
| M8-T4 | GPT Researcher (digest-gepinnt) als Quadlet auf `ghostnet-ki` im Production-Netz, Port `10.0.0.90:8085` (Firewall: nur NPM); Env: `OPENAI_BASE_URL=http://llama-cpp:8080/v1`, `OPENAI_API_KEY`=Placeholder-Secret, `FAST_LLM`/`SMART_LLM`=Production-Alias, Search via SearXNG (custom retriever, `SEARXNG_URL=http://searxng:8080`) | `llm-server/llm/ansible` (neue Rolle `gpt_researcher`, Playbook `research.yml`) | Harness |