GNMON-001 M6 abgenommen: Dashboard oeffentlich via mon.ghostnet.selfhost.eu (Keycloak-OIDC)
Kette: Browser -> https://mon.ghostnet.selfhost.eu (NPM CT-103 ID 14, LE-TLS, Force SSL, WS-Support, X-Forwarded-Proto/Host + 32k-Puffer) -> 10.0.0.90:8080 (nftables gnmon_firewall: nur von 10.0.0.10) -> Blazor v0.3.2 -> Keycloak Realm Ghost.net, Client gnai-dashboard, Rollen gnai-dashboard-user/-admin. Neu/geaendert: - Rolle gnmon_firewall (nftables auf ghostnet-ki, Policy ACCEPT, 8080 nur von NPM, Monitoring-Ports non-loopback-drop), Tag firewall in monitor.yml - Dashboard-Bind 10.0.0.90:8080 (Assertion: LAN-Bind nur mit Firewall-Tag); Image v0.3.2; Playbook-Verifikation akzeptiert 200/302 mit Forwarded-Headern - App: ClientId gnai-dashboard, Auth:AllowedRoles konfigurierbar, KnownNetworks/KnownProxies per .Clear() (leere Initializer = Loopback-Default), GetClaimsFromUserInfoEndpoint=true (realm-roles-Mapper-Flags im Realm unset), SaveTokens=true (Logout: id_token_hint), Cookie AccessDeniedPath /access-denied + Page (sonst Redirect-Loop), csproj PrunePackageData=false + Containerfile ohne --no-restore (sonst fehlt blazor.web.js im Image -> Blazor-Circuit startet nicht) - KeycloakRealmRolesClaimTransformation auf ClaimTypes.Role + [gnmon-auth]-Log - CT-100: Adoption 09.11. (pct exec), Split-DNS mon -> 10.0.0.10 live; Befunde gefixt: dns_pihole_hosts_records in allen 3 Inventaren gespiegelt, FTLCONF_dns_hosts als eine ';'-gejointe Environment-Zeile (systemd: letzter Key gewinnt); gnmon_alloy doppelte Key korrigiert - Doku: GNMON-000 M6 abgenommen (alle Befunde), GNMON-001 v2.2, GNAI-000 Monitoring/DNS-Zeilen, GNAI-006 v3.1 (Proxy-Host 14), GNAI-012 Stand E2E 09.11.2026: unauth -> 302 mit PAR request_uri; Direktzugriff 10.0.0.90:8080 gedroppt; blazor.web.js 200 text/javascript; Login ghost -> Dashboard 200 mit Live-Daten, Unterseiten + WebSocket ok; testuser ohne Rollen -> saubere 403; /logout ok; monitor.yml gesamt ok=84 changed=0. Server-Image-Store aufgeraeumt (v0.3.2 + Rollback v0.2.0/v0.1.0). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -91,11 +91,11 @@ Hauptverzeichnisse `llm-server/host/` (Grundkonfiguration des Servers),
|
||||
| LLM-Serving | drei gepinnte Profile (Swift 1.0, Swift 1.5, Unsloth); Testing-Abnahme 64k/128k je Profil (GNAI-010 10.5–10.9); Production-Umgebung live mit Swift 1.5 Q6_K seit 06.11.2026 (Betreiberbeschluss 05.11., GNAI-009 10.4) inklusive Health, Alias und Inferenztest; exklusive Umschaltmechanik mit Recovery (GNAI-008 14.6, T1–T7; nach Neustart 09.11.2026 `gn_ai_active_env{env="production"}=1` verifiziert) | öffentlicher Nutzerpfad (M6), LLM-Metriken jenseits `gn_ai_active_env`, Nutzerakzeptanzprüfung (GNAI-009 5.3) |
|
||||
| Deployment | lokales Ansible-Control-Projekt und idempotente Hostrollen; Production-Inventar mit Referenz- und Rollback-Profil, `ai_environment_switch` und Backup-Timer deployt und abgenommen (GNAI-008 14.6) | statische CI, Runner, geschützte Freigaben und automatisierter Rollback über die Delivery-Kette |
|
||||
| VPN | wg-easy v15.4.0; einziger Peer `ghost-laptop` als Server Admin; native nftables-Zielpolicy und NAT, Legacy-Bereinigung, Fremdnetz-, Positiv-/Negativ-, Dienst- und LXC-Wiederanlauftests bestanden; CT 104 am 07.10.2026 als zwölftes Ziel praktisch abgenommen | WAN-/IPv6-Managementport-Isolation, Backup-Restore, wg-easy-GUI-HTTPS und KI-Server-Test bei eingeschaltetem Host |
|
||||
| DNS / Pi-hole | CT 100 unter `10.0.0.14` mit digest-gepinntem Pi-hole 2026.09.0 als Podman-Quadlet; SSH/nftables, UDP/TCP-DNS, Split-DNS, Blocking/Allowlist, FRITZ!Box-Cutover, LXC-Reboot und Stop-Mode-Backup am 01.10.2026 abgenommen; Ansible-Projekt vorhanden, Split-DNS-Record `mon.ghostnet.selfhost.eu → 10.0.0.10` vorbereitet (Deploy blockiert: noch kein `ansible-deploy` auf CT 100, Stand 09.11.2026) | vollständige App-/OIDC-Regression, praktischer FRITZ!Box-Rollback, mobile DuckDuckGo-/IPv6-Strategie, WireGuard-Profile, hostunabhängiger Restore-Test und die Production-Adoption des Ansible-Projekts |
|
||||
| DNS / Pi-hole | CT 100 unter `10.0.0.14` mit digest-gepinntem Pi-hole 2026.09.0 als Podman-Quadlet; SSH/nftables, UDP/TCP-DNS, Split-DNS, Blocking/Allowlist, FRITZ!Box-Cutover, LXC-Reboot und Stop-Mode-Backup am 01.10.2026 abgenommen; Ansible-Projekt am 09.11.2026 adoptiert (ansible-deploy via pct; `site.yml`/`verify-production` `changed=0`) und Split-DNS-Record `mon.ghostnet.selfhost.eu → 10.0.0.10` live (verifiziert per `dig @10.0.0.14`) | vollständige App-/OIDC-Regression, praktischer FRITZ!Box-Rollback, mobile DuckDuckGo-/IPv6-Strategie, WireGuard-Profile, hostunabhängiger Restore-Test |
|
||||
| Reverse Proxy | CT-103-Zugänge, SSH-/Firewall-Baseline, Reboot und lokales Backup abgenommen; NPM 2.15.1 routet öffentlichen OIDC- und internen Admin-vHost getrennt; öffentliche Keycloak-Administration liefert 403; vollständiger Ansible-Sollzustand importiert und adoptiert (07.11.2026; preflight/verify-production/`site.yml --check` am 09.11.2026 ohne Befund, `changed=0`) | Fail2Ban-Jails/Bans und Wiederanlauf; hostunabhängige Backupkopie/Restore-Test; NPM-Proxyhost `mon.ghostnet.selfhost.eu` für das Monitoring-Dashboard (M6) |
|
||||
| Keycloak | CT 102 unter `10.0.0.4` reproduzierbar per Ansible aufgebaut; gepinntes Keycloak 26.2.4 und PostgreSQL 16.15, Restore von CT 104, Container-/DB-Härtung, NPM-Cutover, interner Adminzugang, öffentliche Admin-Sperre, realer Vaultwarden-OIDC-Login und LXC-Neustart abgenommen | 14-tägige Stabilisierungsphase, praktischer NPM-Rückfall auf CT 104, Betriebs-/Backup-/Restore-SOP und anschließende Rückfallbereinigung |
|
||||
| Encoding | Konto, Pfade, eigener rootless Store und CPU-Isolation per Ansible verwaltet und verifiziert; NFS-Mount `/var/lib/ghostnet-pipeline` aktiv (verifiziert 09.11.2026); Planungsabschluss 19.10.2026 (Pipeline GNENC-002, Speicher auf CT-101); Monitoring-Anbindung umgesetzt (GNMON-000 M1–M5) | Implementierung (Images, Quadlets, Skripte, Worker); Lasttest und Limit-Feintuning; SMB-Output-Pickup als geschlossener Ablauf |
|
||||
| Monitoring | M1–M5 produktiv auf `10.0.0.90` (System-Scope, Konten `gn-monitor` 986 / `gn-dashboard` 984): node_exporter + AMD-Textfile-Collector, VictoriaMetrics, Loki + Alloy, vmalert + Alertmanager (inkl. Regelgruppe `gnmon-ai` mit `GnAiEnvironmentDown`), Dashboard v0.2.0 host-lokal auf `127.0.0.1:8080`; alle Dienst-Ports host-lokal; nach Host-Neustart 09.11.2026 wieder vollständig aktiv verifiziert (GNMON-000) | M6 externe Freigabe (NPM `mon.ghostnet.selfhost.eu` + Keycloak-OIDC-Client `gn-dashboard`), echter SMTP-Versand, LLM-Metriken jenseits `gn_ai_active_env`, Retention-Feintuning |
|
||||
| Monitoring | M1–M6 produktiv auf `10.0.0.90` (System-Scope, Konten `gn-monitor` 986 / `gn-dashboard` 984): node_exporter + AMD-Textfile-Collector, VictoriaMetrics, Loki + Alloy, vmalert + Alertmanager (inkl. `gnmon-ai`/`GnAiEnvironmentDown`), Dashboard **v0.3.2 öffentlich über `https://mon.ghostnet.selfhost.eu`** (NPM CT-103 ID 14, LE-TLS; Keycloak-OIDC Realm Ghost.net, Client `gnai-dashboard`, Rollen `gnai-dashboard-user`/`-admin`; 8080 per nftables nur von 10.0.0.10; E2E inkl. 403-Negativtest und WebSocket-Circuit bestanden 09.11.2026, GNMON-000 M6) | echter SMTP-Versand, LLM-Metriken jenseits `gn_ai_active_env`, Retention-Feintuning, externer WireGuard-Zugriff auf mon (DNS/TLS öffentlich, praktisch ungetestet) |
|
||||
| Samba (CT 101) | Share-Bestand in GNAI-017 dokumentiert; Ansible-Projekt nach GNAI-019 gebaut und lokal verifiziert; Runbooks vorhanden; In-Place-Upgrade auf Debian 13 am 21.10.2026; smb.conf-Verlust beim Upgrade aus vzdump-Backup wiederhergestellt, Media-Shares und Workstation-Mounts verifiziert | produktive Adoption (Platzhalter, Schlüssel, Convergence, Verifikation), NFS-Export und Encoding-Shares produktiv, UID/GID-Abgleich produktiv, Backup-/Restore-Test |
|
||||
|
||||
Ein Zielbild, eine Betreiberangabe oder ein erfolgreicher Teiltest gilt nicht als
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**Dokumenten-ID:** GNMON-000-DOC
|
||||
**Stand:** 2026-11-09
|
||||
**Status:** Revision v2.0 (03.11.2026) übernommen; M1–M5 produktiv auf Workstation + KI-Server; M6 (NPM + Keycloak-OIDC) App-/Server-seitig vorbereitet, externe Freigabe wartet auf Betreiber-Schritte
|
||||
**Status:** Revision v2.0 (03.11.2026) übernommen; M1–M6 produktiv — Dashboard öffentlich über `https://mon.ghostnet.selfhost.eu` mit Keycloak-OIDC (abgenommen 09.11.2026)
|
||||
|
||||
## Dokumente
|
||||
|
||||
@@ -330,37 +330,71 @@ Realm `Ghost.net` (Vaultwarden-Realm, Issuer
|
||||
ergänzt; der Production-Deploy scheitert zunächst, weil auf CT-100 noch
|
||||
**kein `ansible-deploy`-Konto existiert** (Adoption steht aus, siehe
|
||||
Betreiber-Schritte).
|
||||
- **Betreiber-Schritte (offen):**
|
||||
1. Keycloak: einmalig `kcadm config credentials` als Admin im
|
||||
`ghostnet-keycloak`-Container (Passwort-Prompt), danach legt der
|
||||
Agent Client `gn-dashboard` (confidential, Standard-Flow, Redirect
|
||||
`https://mon.ghostnet.selfhost.eu/signin-oidc`), Realm-Rolle
|
||||
`dashboard-admin` und Rollen-Zuweisung an; Secret wird nur in die
|
||||
host-lokale dashboard-secrets.env geschrieben. MFA-Hinweis: eine
|
||||
reichweitenweite Realm-Policy könnte den produktiven
|
||||
Vaultwarden-OIDC beeinflussen — Ausgestaltung ist
|
||||
Betreiberentscheidung (z. B. Conditional Flow nur für die Rolle).
|
||||
2. CT-100: Adoption-Bootstrap (`bootstrap.yml` auf Bootstrap-Inventar,
|
||||
`--ask-become-pass`) → Agent deploys den DNS-Record.
|
||||
3. CT-103: Der Ansible-Nachbau ist abgeschlossen — Projekt unter
|
||||
`proxmox/lxc/ct-103-reverse-proxy/ansible/`, am 07.11.2026 adoptiert
|
||||
und am 09.11.2026 verifiziert (preflight ok=15, verify-production
|
||||
ok=27 changed=0, `site.yml --check` changed=0; GNAI-006 v3.0).
|
||||
Verbleibend: Proxy-Host `mon.ghostnet.selfhost.eu` → `10.0.0.90:8080`
|
||||
in NPM anlegen (NPM-Proxyhosts sind Runtime-Daten und werden nicht
|
||||
per Ansible verwaltet), WebSocket Support und Block Common Exploits
|
||||
aktiv, SSL/Redirect wie die bestehenden Hosts (Vaultwarden-Muster).
|
||||
Danach: Bind des Dashboards auf die LAN-IP + nftables „8080 nur von
|
||||
10.0.0.10" + `Auth__Enabled=true` + E2E-Abnahme (echter Login,
|
||||
Rollen-403-Negativtest, Blazor-Circuit über WebSocket hinter Proxy).
|
||||
- **Abnahme M6 (09.11.2026, alle bestanden):** Alle drei Betreiber-Schritte
|
||||
wurden durchgeführt und agent-seitig verifiziert:
|
||||
1. **Keycloak (Realm `Ghost.net`, Betreiber-GUI):** Client **`gnai-dashboard`**
|
||||
(confidential, Standard Flow, Redirects
|
||||
`https://mon.ghostnet.selfhost.eu/signin-oidc` +
|
||||
`/signout-callback-oidc`, Web Origin `https://mon.ghostnet.selfhost.eu`),
|
||||
Realm-Rollen **`gnai-dashboard-user`** / **`gnai-dashboard-admin`**
|
||||
(Scope `roles`, Mapper `realm roles` mit Add-to-ID-token/access-token/
|
||||
userinfo ON — im restaurierten Realm waren die Flags unset, das ID-Token
|
||||
enthielt dadurch kein `realm_access`), zugewiesen an User `ghost`.
|
||||
Secret liegt ausschließlich in `/etc/gnmon/dashboard-secrets.env`
|
||||
(gn-dashboard:gn-dashboard 0640; Keys `Auth__Enabled`,
|
||||
`Auth__ClientSecret`, `Auth__AllowedRoles=gnai-dashboard-user,gnai-dashboard-admin`)
|
||||
— nie im Repo/Chat. Keine Änderungen an Authentication-Flows (MFA am
|
||||
Vaultwarden-Login unberührt).
|
||||
2. **CT-100:** Adoption per `pct exec` (ansible-deploy 1002 +
|
||||
`AllowUsers` + sudoers) am 09.11.2026; danach `verify-deploy-access`
|
||||
ok=5, `site.yml` ok=61 changed=11 dann `changed=0`, `verify-production`
|
||||
ok=32 changed=0. Split-DNS `mon.ghostnet.selfhost.eu → 10.0.0.10` live
|
||||
(`dig @10.0.0.14` verifiziert; öffentlich bleibt Wildcard → WAN).
|
||||
**Befund:** die Inventare hatten `dns_pihole_hosts_records` gespiegelt —
|
||||
der neue Record musste in allen drei Inventaren ergänzt werden;
|
||||
außerdem darf die Quadlet-Template nur EINE `FTLCONF_dns_hosts`-Zeile
|
||||
emittieren (systemd: letzter Key gewinnt — sonst fällt auth-admin auf
|
||||
Upstream zurück). Beides gefixt.
|
||||
3. **CT-103:** Proxy-Host ID 14 `mon.ghostnet.selfhost.eu → 10.0.0.90:8080`
|
||||
(WebSocket Support, Block Common Exploits, LE-Cert `npm-20`, Force SSL,
|
||||
HTTP/2, HSTS) + Advanced-Block
|
||||
`proxy_set_header X-Forwarded-Proto $scheme; X-Forwarded-Host $host;`
|
||||
(NPM 2.15.1 setzt sonst nur das leere `$x_forwarded_proto`) sowie
|
||||
`proxy_buffer_size 32k; proxy_buffers 8 32k; proxy_busy_buffers_size 64k;`
|
||||
(großer Auth-Cookie nach Login → sonst 502 „upstream sent too big
|
||||
header“).
|
||||
4. **KI-Server:** Rolle `gnmon_firewall` (nftables, Policy ACCEPT, nur
|
||||
8080 von 10.0.0.10 + Monitoring-Ports non-loopback-drop; `changed=0`
|
||||
idempotent), Dashboard-Bind auf `10.0.0.90:8080` (Assertion erlaubt LAN-Bind
|
||||
nur mit aktivem Firewall-Tag), Image **v0.3.2** deployt.
|
||||
**App-Befunde (v0.2.x → v0.3.2):** ClientId an `gnai-dashboard` angepasst;
|
||||
`Auth:AllowedRoles` konfigurierbar; `KnownNetworks/KnownProxies` per
|
||||
`.Clear()` geleert (leere `{ }`-Initialisierung behält den Loopback-
|
||||
Default — sonst ignoriert .NET die NPM-Forwarded-Header und die
|
||||
redirect_uri wäre intern → PAR 400); `GetClaimsFromUserInfoEndpoint=true`
|
||||
(realm-roles-Mapper-Flags); `SaveTokens=true` (Logout braucht
|
||||
id_token_hint); Cookie-`AccessDeniedPath=/access-denied` + Seite
|
||||
(sonst Redirect-Loop auf /Account/AccessDenied); csproj
|
||||
`PrunePackageData=false` + Containerfile ohne `--no-restore` (sonst
|
||||
fehlt `wwwroot/_framework/blazor.web.js` im Image → Blazor-Circuit
|
||||
startet nicht, 404).
|
||||
**E2E-Verifikation 09.11.2026:** unauth `GET /` via NPM → 302 zu
|
||||
`auth.../realms/Ghost.net/.../auth?client_id=gnai-dashboard&request_uri=...`
|
||||
(PAR 201); Direktzugriff `https://10.0.0.90:8080` von der Workstation →
|
||||
gedroppt (nftables, curl 000); `blazor.web.js` via NPM → 200
|
||||
`text/javascript`; Browser-Login als `ghost` → Dashboard 200 mit Live-Daten,
|
||||
Unterseiten + WebSocket-Circuit hinter NPM ok; Login als `testuser` ohne
|
||||
Rollen → saubere 403-Seite `/access-denied`; `/logout` → Keycloak-Logout
|
||||
ohne id_token_hint-Fehler; Gesamtsuite `monitor.yml` ok=84 changed=0.
|
||||
Journal-Evidenz: `[gnmon-auth] realm_roles=gnai-dashboard-user,...,gnai-dashboard-admin`.
|
||||
|
||||
## Noch offen (Rest)
|
||||
|
||||
1. GNMON-001 v2.0 Abschnitt 9, Restpunkte: Metrics-Account-Identität,
|
||||
UID/GID `gn-monitor` und Chart-Bibliothek sind entschieden/umgesetzt;
|
||||
NPM-Hostname ist entschieden (`mon.ghostnet.selfhost.eu`), der
|
||||
Keycloak-Client folgt mit den M6-Betreiber-Schritten (oben). Offen
|
||||
bleiben LLM-Metriken jenseits `gn_ai_active_env` (z. B. Tokens/
|
||||
UID/GID `gn-monitor` (986), Chart-Bibliothek (Braille), NPM-Hostname
|
||||
(`mon.ghostnet.selfhost.eu`) und Keycloak-Client (`gnai-dashboard` +
|
||||
Rollen) sind entschieden/umgesetzt (M6, oben). Offen bleiben
|
||||
LLM-Metriken jenseits `gn_ai_active_env` (z. B. Tokens/
|
||||
Latenzen der Inference-Engine) und die Retention-Feinjustierung.
|
||||
2. keep-id-Ursachenanalyse (crun/Overlay-Rechte der gn-dashboard-Storage)
|
||||
bei Bedarf; Entscheidung zum Default-Mapping steht in Abschnitt M5.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
**Dokumenten-ID:** GNMON-001-PLAN
|
||||
**Titel:** Host-Monitoring auf dem KI-Server: Systemmetriken, Log-Pipeline und Blazor-Dashboard
|
||||
**Stand:** 2026-11-09
|
||||
**Status:** Revidierter Plan (v2.0) nach Betreiberentscheidungen vom 03.11.2026; M1–M5 produktiv umgesetzt (belegter Stand in GNMON-000), M6 externe Freigabe in Vorbereitung
|
||||
**Status:** Revidierter Plan (v2.0) nach Betreiberentscheidungen vom 03.11.2026; M1–M6 produktiv umgesetzt inkl. OIDC-Freigabe (belegter Stand in GNMON-000)
|
||||
**Referenzen:** [GNENC-001](https://git.ghostnet.selfhost.eu/ghostnet.ai/infrastructure/raw/branch/main/docs/platform/llm-server/encoding/GNENC-001-PLAN_Architecture.md), [GNENC-002](https://git.ghostnet.selfhost.eu/ghostnet.ai/infrastructure/raw/branch/main/docs/platform/llm-server/encoding/GNENC-002-PLAN_Pipeline.md), [GNAI-005](https://git.ghostnet.selfhost.eu/ghostnet.ai/infrastructure/raw/branch/main/docs/platform/GNAI-005-SEC_Access-Control.md), [GNAI-006](https://git.ghostnet.selfhost.eu/ghostnet.ai/infrastructure/raw/branch/main/docs/platform/proxmox-server/lxc/ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md)
|
||||
|
||||
## Änderungsverlauf
|
||||
@@ -13,6 +13,7 @@
|
||||
| 19.10.2026 | 1.0 | Betreiber | Planungsabschluss: Metrics-Collector (system.json) + Flask-Dashboard |
|
||||
| 03.11.2026 | 2.0 | Betreiber / Mistral Vibe | Revision: Dashboard auf ASP.NET Core Blazor Server; Metriken über VictoriaMetrics + Exporter statt system.json-Schnappschuss; neue Log-Pipeline (Alloy + Loki) für journald-, Container- und Encoding-Logs |
|
||||
| 09.11.2026 | 2.1 | Mistral Vibe | Umsetzungsabweichungen gegenüber v2.0 nachgeführt (belegter Stand in GNMON-000): `gn-monitor` hat UID/GID **986** (die geplante 983 war an `gn-download` vergeben), Charts als eigene Braille-Komponente statt ApexCharts, NPM-Hostname `mon.ghostnet.selfhost.eu` entschieden; M1–M5 sind produktiv auf dem KI-Server (System-Scope) und der Workstation (User-Scope) ausgerollt |
|
||||
| 09.11.2026 | 2.2 | Mistral Vibe | M6 umgesetzt (Abschnitt 7 wird damit Realität): nftables-Rolle `gnmon_firewall` (8080 nur von NPM 10.0.0.10), Dashboard-Bind auf `10.0.0.90:8080`, OIDC gegen Keycloak-Client `gnai-dashboard` (Realm Ghost.net, Rollen `gnai-dashboard-user`/`gnai-dashboard-admin`); NPM-Proxyhost mit X-Forwarded-Proto/Host + vergrößerten Puffern. Details und Befunde in GNMON-000 M6 |
|
||||
|
||||
## Änderungen gegenüber v1.0
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
**Dokumenten-ID:** GNAI-012-PLAN
|
||||
**Titel:** Pi-hole-LXC, FRITZ!Box-DNS und Split-DNS für interne Dienste
|
||||
**Status:** Implementiert und im LAN produktiv; Ansible-Sollzustand als CT-Projekt angelegt, privilegierte Live-Adoption und klar ausgewiesene Folgepunkte offen
|
||||
**Stand:** 21.10.2026
|
||||
**Status:** Implementiert und im LAN produktiv; Ansible-Sollzustand als CT-Projekt angelegt und am 09.11.2026 privilegiert adoptiert (ansible-deploy via pct exec; `site.yml`/`verify-production` konvergent `changed=0`); Split-DNS-Record `mon.ghostnet.selfhost.eu → 10.0.0.10` seit 09.11.2026 live (GNMON-M6). Klar ausgewiesene Folgepunkte offen
|
||||
**Stand:** 2026-11-09
|
||||
**Referenzen:** [Projekt-Roadmap](../../../../GNAI-001-PLAN_Project-Roadmap.md), [Zugriffskonzept](../../../GNAI-005-SEC_Access-Control.md), [LXC-SSH-Architektur](../../GNAI-011-SEC_LXC-SSH-Architecture.md), [Reverse Proxy](../ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md), [WireGuard](../ct-105-wireguard/GNAI-007-SEC_VPN.md)
|
||||
|
||||
## 1. Auftrag und Umsetzungsergebnis
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
| 2026-10-14 | 2.8 | Codex | NPM auf den reproduzierten CT 102 umgeschaltet; öffentliche Admin-Sperre 403, interner Admin-vHost 200, Discovery/OIDC und realer Vaultwarden-Login abgenommen. |
|
||||
| 2026-10-31 | 2.9 | spektr / Mistral Vibe | Lesenden Infrastruktur-Audit vor dem LLM-Ausbau durchgeführt (Abschnitt 2.4): Dienste, Image-Pins, SSH- und Dateihärtung, Firewall-Verhaltenstests, TLS, DNS und Keycloak-Pfade geprüft; keine Abweichung. Fail2Ban-Funktionsabnahme bleibt offen. |
|
||||
| 2026-11-09 | 3.0 | Mistral Vibe | Ansible-Sollzustand im Repository importiert (`proxmox/lxc/ct-103-reverse-proxy/ansible/`) und am 07.11.2026 adoptiert (Konten `ghost-agent`/`ghost`/`ansible-deploy`, verwaltetes nftables, NPM-/Fail2Ban-Quadlets). Verifiziert 09.11.2026: `preflight.yml` (agent) ok=15 failed=0, `verify-production.yml` (production) ok=27 changed=0 failed=0, `site.yml --check` changed=0 — Host und Sollzustand sind konvergent. |
|
||||
| 2026-11-09 | 3.1 | spektr / Mistral Vibe | Proxy-Host ID 14 `mon.ghostnet.selfhost.eu → 10.0.0.90:8080` angelegt (Abschnitt 7): WebSocket Support, Block Common Exploits, LE-Zertifikat, Force SSL, HSTS; Advanced-Config mit `X-Forwarded-Proto $scheme`/`X-Forwarded-Host $host` (NPM setzt sonst nur das leere `$x_forwarded_proto`) und `proxy_buffer_size 32k` (großer OIDC-Cookie). GNMON-M6-Abnahme siehe GNMON-000. |
|
||||
|
||||
---
|
||||
|
||||
@@ -392,6 +393,7 @@ Routen aus dem bisherigen Quelleninventar; Keycloak-Backend vom Betreiber erneut
|
||||
| 7 | `auth.ghostnet.selfhost.eu` | `10.0.0.4:8080` | Keycloak Identity Provider |
|
||||
| 10 | `japan.ghostnet.selfhost.eu` | `10.0.0.23:80` | Japanese Web App |
|
||||
| 12 | `vault.ghostnet.selfhost.eu` | `10.0.0.47:8080` | Vaultwarden Password Manager |
|
||||
| 14 | `mon.ghostnet.selfhost.eu` | `10.0.0.90:8080` | GNMON-Dashboard (Blazor, OIDC) — WebSocket Support + Block Common Exploits + LE-TLS + Force SSL; Advanced: `X-Forwarded-Proto $scheme`, `X-Forwarded-Host $host`, `proxy_buffer_size 32k` (großer OIDC-Cookie), Split-DNS via CT 100 seit 09.11.2026 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -73,11 +73,17 @@ gnmon_loki_image_ref: docker.io/grafana/loki:3.6.19
|
||||
gnmon_alertmanager_image_ref: docker.io/prom/alertmanager:v0.34.2
|
||||
gnmon_vmalert_image_ref: docker.io/victoriametrics/vmalert:v1.154.1
|
||||
|
||||
# --- Firewall (M6, nur System-Scope auf ghostnet-ki) -------------------------
|
||||
gnmon_firewall_scope: system
|
||||
# 8080 nur von NPM (CT-103) erreichbar (gnmon_firewall); Default-Werte siehe Rolle.
|
||||
|
||||
# --- Dashboard ---------------------------------------------------------------
|
||||
gnmon_dashboard_scope: system
|
||||
gnmon_dashboard_systemd_scope: system
|
||||
gnmon_dashboard_quadlet_dir: /etc/containers/systemd/users/984
|
||||
# Transportiertes Image (Workstation-Build, podman save/load am 06.11.2026:
|
||||
# docker.io/ghostnet/dashboard:v0.1.0, ID 1b71e6d35069 — identisch zur
|
||||
# Workstation, Build aus images/dashboard/Containerfile).
|
||||
gnmon_dashboard_image_ref: docker.io/ghostnet/dashboard:v0.2.0
|
||||
# M6: Bind auf die LAN-IP; nftables (gnmon_firewall) lässt nur 10.0.0.10 (NPM) zu.
|
||||
gnmon_dashboard_http_listen: "10.0.0.90:8080"
|
||||
# Transportiertes Image (Workstation-Build, podman save/load am 09.11.2026).
|
||||
# v0.2.1: konfigurierbare Auth:AllowedRoles; v0.2.2 (ID 518f88349c6c): ClientId
|
||||
# an den Keycloak-Client "gnai-dashboard" angepasst. Build aus images/dashboard/Containerfile.
|
||||
gnmon_dashboard_image_ref: docker.io/ghostnet/dashboard:v0.3.2
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
roles:
|
||||
- role: gnmon_accounts
|
||||
tags: [accounts, never]
|
||||
- role: gnmon_firewall
|
||||
tags: [firewall]
|
||||
- role: gnmon_collector
|
||||
tags: [collector]
|
||||
- role: gnmon_victoria_metrics
|
||||
@@ -120,23 +122,33 @@
|
||||
when: gnmon_vmalert_selftest_rule | bool
|
||||
tags: [alerting]
|
||||
|
||||
- name: Wait for the dashboard to answer on the host loopback
|
||||
# M6: with Auth enabled, "/" answers 302 (OIDC challenge via PAR toward
|
||||
# Keycloak) instead of 200; without auth it serves the Blazor shell (200).
|
||||
# The forwarded headers simulate the NPM ingress so the OIDC redirect
|
||||
# URI resolves to the external host registered in Keycloak.
|
||||
- name: Wait for the dashboard to answer
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ gnmon_dashboard_http_listen }}/"
|
||||
status_code: 200
|
||||
status_code: [200, 302]
|
||||
headers:
|
||||
X-Forwarded-Proto: https
|
||||
X-Forwarded-Host: mon.ghostnet.selfhost.eu
|
||||
register: gnmon_dashboard_ready
|
||||
retries: 20
|
||||
delay: 3
|
||||
until: gnmon_dashboard_ready.status == 200
|
||||
until: gnmon_dashboard_ready.status in [200, 302]
|
||||
tags: [dashboard]
|
||||
|
||||
- name: Verify the dashboard serves the Blazor shell
|
||||
- name: Verify the dashboard answers (200 shell or 302 OIDC challenge)
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ gnmon_dashboard_http_listen }}/"
|
||||
status_code: 200
|
||||
status_code: [200, 302]
|
||||
headers:
|
||||
X-Forwarded-Proto: https
|
||||
X-Forwarded-Host: mon.ghostnet.selfhost.eu
|
||||
return_content: false
|
||||
register: gnmon_dashboard_shell
|
||||
until: gnmon_dashboard_shell.status == 200
|
||||
until: gnmon_dashboard_shell.status in [200, 302]
|
||||
retries: 3
|
||||
delay: 2
|
||||
tags: [dashboard]
|
||||
|
||||
@@ -24,11 +24,9 @@ gnmon_alloy_loki_push_url: "http://127.0.0.1:3100/loki/api/v1/push"
|
||||
|
||||
# journald source. In user-scope operation the sd-journal auto-discovery
|
||||
# only opens the user journal; the workstation inventory therefore sets
|
||||
# an explicit journal path. Empty string = auto-discovery.
|
||||
# an explicit journal path. Empty string = auto-discovery. Needs the
|
||||
# systemd-journal group membership of the run user in system scope.
|
||||
gnmon_alloy_journal_path: ""
|
||||
gnmon_alloy_journal_max_age: "12h"
|
||||
|
||||
# journald source (needs systemd-journal group membership).
|
||||
gnmon_alloy_journal_enabled: true
|
||||
gnmon_alloy_journal_max_age: "12h"
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ gnmon_dashboard_quadlet_dir: >-
|
||||
if gnmon_dashboard_scope == 'system'
|
||||
else lookup('ansible.builtin.env', 'HOME') ~ '/.config/containers/systemd' }}
|
||||
|
||||
# Transported image (built from images/dashboard/Containerfile); v0.2.0
|
||||
# adds the configuration-driven OIDC layer (M6, GNMON-000). The image is
|
||||
# transported (podman save/load), so the inventory pins the tag ref either
|
||||
# way.
|
||||
gnmon_dashboard_image_ref: docker.io/ghostnet/dashboard:v0.2.0
|
||||
# Transported image (built from images/dashboard/Containerfile); v0.2.1
|
||||
# adds the configuration-driven OIDC layer with configurable Auth:AllowedRoles
|
||||
# (M6, GNMON-000). The image is transported (podman save/load), so the
|
||||
# inventory pins the tag ref either way.
|
||||
gnmon_dashboard_image_ref: docker.io/ghostnet/dashboard:v0.3.2
|
||||
|
||||
# Host loopback only (GNMON-001 section 7); NPM ingress follows in M6.
|
||||
gnmon_dashboard_http_listen: "127.0.0.1:8080"
|
||||
|
||||
@@ -4,10 +4,17 @@
|
||||
that:
|
||||
- gnmon_dashboard_scope in ['user', 'system']
|
||||
- gnmon_dashboard_image_ref is match('^[a-z0-9./:-]+$')
|
||||
- gnmon_dashboard_http_listen is match('^127\.0\.0\.1:[0-9]+$')
|
||||
# M5 default: host loopback. M6: a LAN bind is allowed only in system
|
||||
# scope together with the gnmon_firewall role (8080 restricted to NPM).
|
||||
- >-
|
||||
gnmon_dashboard_http_listen is match('^127\.0\.0\.1:[0-9]+$')
|
||||
or (gnmon_dashboard_scope == 'system'
|
||||
and gnmon_firewall_scope | default('user') == 'system'
|
||||
and gnmon_dashboard_http_listen is match('^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+$'))
|
||||
fail_msg: >-
|
||||
gnmon_dashboard requires scope user|system, an image ref and a
|
||||
host-loopback listen address.
|
||||
gnmon_dashboard requires scope user|system, an image ref and either a
|
||||
host-loopback listen address or — in system scope with gnmon_firewall
|
||||
active — a LAN listen address (M6 ingress via NPM only).
|
||||
|
||||
- name: Create the dashboard quadlet directory
|
||||
ansible.builtin.file:
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# gnmon_firewall
|
||||
|
||||
Host-nftables on `ghostnet-ki` (GNMON-001 section 7), system scope only. The
|
||||
workstation inventory (user scope) is a no-op.
|
||||
|
||||
## What it enforces
|
||||
|
||||
- Dashboard port 8080 (M6): reachable **only from NPM** (CT-103,
|
||||
`gnmon_firewall_dashboard_allowed_ip` = 10.0.0.10). NPM terminates TLS and
|
||||
the OIDC redirect; the dashboard itself binds to the LAN address
|
||||
`10.0.0.90:8080` (`gnmon_dashboard_http_listen`).
|
||||
- Monitoring APIs (Loki 3100/9096, VictoriaMetrics 8428, vmalert 8880,
|
||||
Alertmanager 9093, node_exporter 9100): bound to 127.0.0.1 by the services
|
||||
and additionally dropped for non-loopback traffic (defense in depth).
|
||||
|
||||
## What it deliberately does NOT do
|
||||
|
||||
The input policy stays **ACCEPT**: the KI host has no other firewall, and a
|
||||
default-drop policy introduced from the monitoring project could lock out SSH
|
||||
management. A full host firewall is a separate sprint (GNAI-001 M1).
|
||||
`flush ruleset` in the managed `/etc/nftables.conf` removes every other
|
||||
table — do not maintain foreign nftables content on this host.
|
||||
|
||||
## Operations
|
||||
|
||||
- Preview: `ansible-playbook -i inventories/testing/hosts.yml playbooks/monitor.yml --tags firewall --check --diff`
|
||||
- Deploy: same without `--check`.
|
||||
- Verify live: `nft list ruleset` (root), e.g. on the host
|
||||
`sudo nft list table inet gnmon_filter`.
|
||||
- Negative test from the workstation while the dashboard is LAN-bound:
|
||||
`curl -k --max-time 5 https://10.0.0.90:8080/` must time out (dropped),
|
||||
while `https://mon.ghostnet.selfhost.eu/` via NPM answers.
|
||||
@@ -0,0 +1,29 @@
|
||||
# GNMON-001 section 7: host nftables on ghostnet-ki (M6 ingress control).
|
||||
#
|
||||
# System scope only (ghostnet-ki). The workstation (user scope) needs no
|
||||
# host firewall: everything binds to 127.0.0.1 there as well.
|
||||
#
|
||||
# Safety: the input policy stays ACCEPT. This role only adds GNMON-specific
|
||||
# restrictions (dashboard ingress from NPM only, monitoring ports loopback
|
||||
# only). A default-drop host firewall is a separate sprint (GNAI-001 M1)
|
||||
# and must never be introduced from here.
|
||||
|
||||
gnmon_firewall_scope: user
|
||||
|
||||
gnmon_firewall_config_path: /etc/nftables.conf
|
||||
gnmon_firewall_service_name: nftables.service
|
||||
|
||||
# Dashboard ingress (M6): the Blazor dashboard binds to the LAN address,
|
||||
# but only NPM (CT-103) may reach it; NPM terminates TLS and OIDC.
|
||||
gnmon_firewall_dashboard_port: 8080
|
||||
gnmon_firewall_dashboard_allowed_ip: 10.0.0.10
|
||||
|
||||
# Monitoring APIs bind to 127.0.0.1 (GNMON-000 M5); deny non-loopback
|
||||
# access to them anyway (defense in depth, GNMON-001 section 7).
|
||||
gnmon_firewall_loopback_only_ports:
|
||||
- 3100 # Loki HTTP
|
||||
- 9096 # Loki gRPC
|
||||
- 8428 # VictoriaMetrics
|
||||
- 8880 # vmalert
|
||||
- 9093 # Alertmanager
|
||||
- 9100 # node_exporter
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# GNMON-001 section 7: nftables reload handler (system scope).
|
||||
- name: Restart nftables
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ gnmon_firewall_service_name }}"
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
when: gnmon_firewall_scope == 'system'
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
# GNMON-001 section 7: host nftables on ghostnet-ki. System scope only;
|
||||
# the role is a no-op for the workstation (user scope) inventory.
|
||||
|
||||
- name: Validate firewall declarations
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- gnmon_firewall_scope in ['user', 'system']
|
||||
- gnmon_firewall_config_path is match('^/etc/')
|
||||
- gnmon_firewall_dashboard_port | int >= 1024
|
||||
- gnmon_firewall_dashboard_allowed_ip is match('^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$')
|
||||
- gnmon_firewall_loopback_only_ports | length > 0
|
||||
fail_msg: >-
|
||||
gnmon_firewall requires scope user|system, an /etc config path, a
|
||||
dashboard port >= 1024 and a valid NPM ingress IPv4.
|
||||
when: gnmon_firewall_scope == 'system'
|
||||
|
||||
- name: Install nftables (system scope only)
|
||||
ansible.builtin.apt:
|
||||
name: nftables
|
||||
state: present
|
||||
when: gnmon_firewall_scope == 'system'
|
||||
|
||||
- name: Install the managed nftables configuration
|
||||
ansible.builtin.template:
|
||||
src: nftables.conf.j2
|
||||
dest: "{{ gnmon_firewall_config_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
validate: "/usr/sbin/nft --check --file %s"
|
||||
notify: Restart nftables
|
||||
when: gnmon_firewall_scope == 'system'
|
||||
|
||||
- name: Enable and start the nftables service
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ gnmon_firewall_service_name }}"
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
when:
|
||||
- gnmon_firewall_scope == 'system'
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Verify the GNMON ruleset is loaded
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- /usr/sbin/nft
|
||||
- list
|
||||
- ruleset
|
||||
register: gnmon_firewall_ruleset
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when:
|
||||
- gnmon_firewall_scope == 'system'
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Require the dashboard ingress restriction
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'gnmon_filter' in gnmon_firewall_ruleset.stdout"
|
||||
- "('tcp dport ' ~ (gnmon_firewall_dashboard_port | string)) in gnmon_firewall_ruleset.stdout"
|
||||
fail_msg: >-
|
||||
The gnmon_filter table or the dashboard port restriction is missing
|
||||
from the live ruleset.
|
||||
when:
|
||||
- gnmon_firewall_scope == 'system'
|
||||
- not ansible_check_mode
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/sbin/nft -f
|
||||
# {{ ansible_managed }}
|
||||
# GNMON-001 section 7: host nftables on ghostnet-ki, managed by the
|
||||
# gnmon_firewall role (llm-server/monitoring/ansible).
|
||||
#
|
||||
# The input policy deliberately stays ACCEPT: this host has no other
|
||||
# firewall and a default-drop here could lock out SSH management.
|
||||
# This table only enforces the GNMON ingress rules. `flush ruleset`
|
||||
# removes every other table — do not add foreign nftables content to
|
||||
# this host without moving the firewall into its own role/sprint.
|
||||
|
||||
flush ruleset
|
||||
|
||||
table inet gnmon_filter {
|
||||
chain input {
|
||||
type filter hook input priority filter; policy accept;
|
||||
|
||||
iifname "lo" accept
|
||||
|
||||
# M6: dashboard ingress only from NPM (CT-103, {{ gnmon_firewall_dashboard_allowed_ip }}).
|
||||
ip saddr != {{ gnmon_firewall_dashboard_allowed_ip }} tcp dport {{ gnmon_firewall_dashboard_port }} drop
|
||||
|
||||
# Monitoring APIs are bound to 127.0.0.1; deny non-loopback anyway.
|
||||
iifname != "lo" tcp dport { {{ gnmon_firewall_loopback_only_ports | join(', ') }} } drop
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,10 @@ COPY Ghostnet.Dashboard.csproj .
|
||||
RUN dotnet restore Ghostnet.Dashboard.csproj
|
||||
|
||||
COPY . .
|
||||
RUN dotnet publish Ghostnet.Dashboard.csproj -c Release -o /app --no-restore
|
||||
# No --no-restore: with the cached restore the publish could run with stale
|
||||
# package data and drop wwwroot/_framework/blazor.web.js (404 in the
|
||||
# container, Befund 09.11.2026); a full restore+publish keeps it.
|
||||
RUN dotnet publish Ghostnet.Dashboard.csproj -c Release -o /app
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
WORKDIR /app
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@page "/access-denied"
|
||||
@attribute [AllowAnonymous]
|
||||
@layout MainLayout
|
||||
|
||||
<h3>Zugriff verweigert (403)</h3>
|
||||
<p>Dein Keycloak-Account (Realm <code>Ghost.net</code>) hat keine der Realm-Rollen
|
||||
<code>gnai-dashboard-user</code> oder <code>gnai-dashboard-admin</code>.</p>
|
||||
<p>Bitte wende dich an den Betreiber, um eine der Rollen zugewiesen zu bekommen,
|
||||
oder melde dich mit einem anderen Account an: <a href="/login">Login</a></p>
|
||||
@@ -5,8 +5,13 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
|
||||
<!-- SDK 10 prune package data is unavailable for the system-installed
|
||||
runtime pack; irrelevant for framework-dependent builds. -->
|
||||
<!-- .NET 10 package pruning dropped wwwroot/_framework/blazor.web.js from
|
||||
the published output (it lives in the prunable Internal.Assets
|
||||
package), so the container served 404 for blazor.web.js and the
|
||||
Blazor circuit never started (Befund 09.11.2026). Disable pruning;
|
||||
AllowMissingPrunePackageData is required because the system-installed
|
||||
runtime pack ships no prune data (NETSDK1226 otherwise). -->
|
||||
<PrunePackageData>false</PrunePackageData>
|
||||
<AllowMissingPrunePackageData>true</AllowMissingPrunePackageData>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -36,8 +36,14 @@ builder.Services.AddHttpClient<AlertmanagerClient>(client =>
|
||||
// --- OIDC (GNMON-001 section 6, M6) ------------------------------------
|
||||
// Auth is purely configuration-driven: disabled (workstation/local
|
||||
// deployments) the DashboardAccess policy authorizes everyone; enabled
|
||||
// the app requires a Keycloak login with the realm role dashboard-admin.
|
||||
// the app requires a Keycloak login with a realm role ai-dashboard or
|
||||
// ai-dashboard-admin (Betreiber-Namenskonvention im Realm Ghost.net).
|
||||
var authEnabled = builder.Configuration.GetValue<bool>("Auth:Enabled");
|
||||
// Realm roles that grant dashboard access (comma-separated, configurable
|
||||
// so the Keycloak naming does not require an app rebuild).
|
||||
var allowedRoles = (builder.Configuration["Auth:AllowedRoles"]
|
||||
?? "ai-dashboard,ai-dashboard-admin")
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
if (authEnabled)
|
||||
{
|
||||
var authority = builder.Configuration["Auth:Authority"]
|
||||
@@ -49,13 +55,16 @@ if (authEnabled)
|
||||
var clientSecret = builder.Configuration["Auth:ClientSecret"]
|
||||
?? throw new InvalidOperationException(
|
||||
"Auth:Enabled requires the client secret via Auth:ClientSecret (environment)");
|
||||
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddCookie()
|
||||
// Forbid after endpoint authorization lands on the COOKIE scheme
|
||||
// (DefaultForbidScheme), so its AccessDeniedPath must point at the page —
|
||||
// the OIDC default /Account/AccessDenied does not exist in this app and
|
||||
// produced a redirect loop (Befund 09.11.2026).
|
||||
.AddCookie(cookie => cookie.AccessDeniedPath = "/access-denied")
|
||||
.AddOpenIdConnect(options =>
|
||||
{
|
||||
options.Authority = authority;
|
||||
@@ -63,14 +72,31 @@ if (authEnabled)
|
||||
options.ClientSecret = clientSecret;
|
||||
options.ResponseType = "code"; // authorization code flow + PKCE
|
||||
options.UsePkce = true;
|
||||
options.SaveTokens = false;
|
||||
options.GetClaimsFromUserInfoEndpoint = false;
|
||||
// Keycloak realm roles live in realm_access.roles; map them onto
|
||||
// role claims in addition to the claims transformation (the
|
||||
// transformation also covers identities without a role claim).
|
||||
options.TokenValidationParameters.RoleClaimType = "role";
|
||||
// The redirect URI is derived from the request host; behind NPM the
|
||||
// X-Forwarded-Host/X-Forwarded-Proto headers (see UseForwardedHeaders
|
||||
// below) restore the external name mon.ghostnet.selfhost.eu, so the
|
||||
// computed https://mon.ghostnet.selfhost.eu/signin-oidc matches the
|
||||
// URI registered in Keycloak. .NET 10 has no RedirectUri property.
|
||||
// SaveTokens is required so the OIDC sign-out redirect carries
|
||||
// id_token_hint (Keycloak end_session rejects logout without it:
|
||||
// "Missing parameters: id_token_hint", Befund 09.11.2026).
|
||||
options.SaveTokens = true;
|
||||
// Pull the full claim set (incl. realm_access.roles) from the
|
||||
// userinfo endpoint: the realm-roles mapper's "Add to ID token" flag
|
||||
// is not set in this realm, so the ID token alone carried no
|
||||
// realm_access and authorization denied everyone (Befund 09.11.2026).
|
||||
options.GetClaimsFromUserInfoEndpoint = true;
|
||||
// Keycloak realm roles live in the realm_access.roles JSON claim;
|
||||
// KeycloakRealmRolesClaimTransformation maps them onto role claims
|
||||
// (ClaimTypes.Role, the default RoleClaimType — overriding it to
|
||||
// "role" broke IsInRole because inbound claim mapping renames "role"
|
||||
// to ClaimTypes.Role, Befund 09.11.2026).
|
||||
options.Scope.Add("openid");
|
||||
options.Scope.Add("profile");
|
||||
// Clean 403 page instead of the default /Account/AccessDenied, which
|
||||
// does not exist in this app and produced a redirect loop in the
|
||||
// browser (Befund 09.11.2026).
|
||||
options.AccessDeniedPath = "/access-denied";
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton<IClaimsTransformation, KeycloakRealmRolesClaimTransformation>();
|
||||
@@ -82,8 +108,9 @@ builder.Services.AddAuthorization(options =>
|
||||
{
|
||||
if (authEnabled)
|
||||
{
|
||||
// Realm role from Ghost.net (see KeycloakRealmRolesClaimTransformation).
|
||||
policy.RequireRole("dashboard-admin");
|
||||
// Realm roles from Ghost.net (see KeycloakRealmRolesClaimTransformation),
|
||||
// configurable via Auth:AllowedRoles.
|
||||
policy.RequireRole(allowedRoles);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,12 +124,21 @@ builder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// TLS terminates at NPM (CT-103); trust its forwarded headers so the
|
||||
// OIDC redirect URIs and HTTPS checks see the external scheme/host.
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
// TLS terminates at NPM (CT-103); trust its forwarded headers so the OIDC
|
||||
// redirect URIs and HTTPS checks see the external scheme/host. Port 8080 is
|
||||
// reachable only from 10.0.0.10 anyway (gnmon_firewall), so clearing the
|
||||
// known-proxy lists is safe here. NOTE: KnownNetworks/KnownProxies must be
|
||||
// .Clear()ed — a `{ }` collection initializer keeps the default loopback
|
||||
// entry, non-loopback proxies are then rejected and the redirect_uri is
|
||||
// computed from the internal 10.0.0.90:8080 host (PAR: "Invalid parameter:
|
||||
// redirect_uri", Befund 09.11.2026).
|
||||
var forwardedHeaders = new ForwardedHeadersOptions
|
||||
{
|
||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto,
|
||||
});
|
||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost,
|
||||
};
|
||||
forwardedHeaders.KnownNetworks.Clear();
|
||||
forwardedHeaders.KnownProxies.Clear();
|
||||
app.UseForwardedHeaders(forwardedHeaders);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
|
||||
+20
-12
@@ -6,8 +6,10 @@ namespace Ghostnet.Dashboard.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Maps Keycloak realm roles (the realm_access.roles JSON claim) onto
|
||||
/// role claims so [Authorize]/RequireRole work with the standard OIDC
|
||||
/// handler (GNMON-001 section 6: realm role dashboard-admin).
|
||||
/// ClaimTypes.Role claims so [Authorize]/RequireRole work with the standard
|
||||
/// OIDC handler (GNMON-001 section 6: realm roles gnai-dashboard-user /
|
||||
/// gnai-dashboard-admin in realm Ghost.net). Fail closed: a malformed
|
||||
/// realm_access claim adds no roles and authorization denies access.
|
||||
/// </summary>
|
||||
public sealed class KeycloakRealmRolesClaimTransformation : IClaimsTransformation
|
||||
{
|
||||
@@ -16,14 +18,12 @@ public sealed class KeycloakRealmRolesClaimTransformation : IClaimsTransformatio
|
||||
|
||||
public Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
|
||||
{
|
||||
if (principal.Identity is not ClaimsIdentity identity || !identity.IsAuthenticated)
|
||||
{
|
||||
return Task.FromResult(principal);
|
||||
}
|
||||
// M6 diagnostic: always log invocation + claim inventory (claim types
|
||||
// only, no values) so a missing realm_access becomes visible.
|
||||
var types = principal.Claims.Select(c => c.Type).Distinct().OrderBy(t => t).ToList();
|
||||
Console.WriteLine($"[gnmon-auth] transform called; authenticated={principal.Identity?.IsAuthenticated}; claim_types={string.Join(",", types)}");
|
||||
|
||||
// Skip when the identity already carries a usable role claim.
|
||||
if (identity.HasClaim(claim =>
|
||||
claim.Type == identity.RoleClaimType && !string.IsNullOrEmpty(claim.Value)))
|
||||
if (principal.Identity is not ClaimsIdentity identity || !identity.IsAuthenticated)
|
||||
{
|
||||
return Task.FromResult(principal);
|
||||
}
|
||||
@@ -31,9 +31,11 @@ public sealed class KeycloakRealmRolesClaimTransformation : IClaimsTransformatio
|
||||
var realmAccess = principal.FindFirst(RealmAccessClaim)?.Value;
|
||||
if (string.IsNullOrWhiteSpace(realmAccess))
|
||||
{
|
||||
Console.WriteLine("[gnmon-auth] realm_access claim MISSING");
|
||||
return Task.FromResult(principal);
|
||||
}
|
||||
|
||||
var mapped = new List<string>();
|
||||
try
|
||||
{
|
||||
using var document = JsonDocument.Parse(realmAccess);
|
||||
@@ -44,17 +46,23 @@ public sealed class KeycloakRealmRolesClaimTransformation : IClaimsTransformatio
|
||||
var value = role.GetString();
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
identity.AddClaim(new Claim(identity.RoleClaimType, value));
|
||||
// Always ClaimTypes.Role: that is the identity's
|
||||
// RoleClaimType under the default token validation
|
||||
// parameters, so IsInRole finds these claims.
|
||||
identity.AddClaim(new Claim(ClaimTypes.Role, value));
|
||||
mapped.Add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
// Malformed realm_access: fall through without roles; the
|
||||
// authorization policy denies access (fail closed).
|
||||
// Malformed realm_access: no roles added; the authorization
|
||||
// policy denies access (fail closed).
|
||||
}
|
||||
|
||||
// Role names are not secret; log them for M6 acceptance evidence.
|
||||
Console.WriteLine($"[gnmon-auth] user={identity.Name} realm_roles={string.Join(",", mapped)}");
|
||||
return Task.FromResult(principal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"Auth": {
|
||||
"Enabled": false,
|
||||
"Authority": "https://auth.ghostnet.selfhost.eu/realms/Ghost.net",
|
||||
"ClientId": "gn-dashboard"
|
||||
"ClientId": "gnai-dashboard"
|
||||
},
|
||||
"Monitoring": {
|
||||
"VictoriaMetrics": "http://127.0.0.1:8428",
|
||||
|
||||
@@ -30,6 +30,8 @@ dns_pihole_upstreams:
|
||||
- 149.112.112.112
|
||||
dns_pihole_hosts_records:
|
||||
- "10.0.0.10 auth-admin.ghostnet.selfhost.eu"
|
||||
# GNMON-001 M6: monitoring dashboard via NPM (CT-103); mirrors the role default.
|
||||
- "10.0.0.10 mon.ghostnet.selfhost.eu"
|
||||
dns_pihole_timezone: Europe/Berlin
|
||||
dns_pihole_database_max_db_days: 30
|
||||
dns_pihole_secret_name: pihole_web_password
|
||||
|
||||
@@ -30,6 +30,8 @@ dns_pihole_upstreams:
|
||||
- 149.112.112.112
|
||||
dns_pihole_hosts_records:
|
||||
- "10.0.0.10 auth-admin.ghostnet.selfhost.eu"
|
||||
# GNMON-001 M6: monitoring dashboard via NPM (CT-103); mirrors the role default.
|
||||
- "10.0.0.10 mon.ghostnet.selfhost.eu"
|
||||
dns_pihole_timezone: Europe/Berlin
|
||||
dns_pihole_database_max_db_days: 30
|
||||
dns_pihole_secret_name: pihole_web_password
|
||||
|
||||
@@ -30,6 +30,8 @@ dns_pihole_upstreams:
|
||||
- 149.112.112.112
|
||||
dns_pihole_hosts_records:
|
||||
- "10.0.0.10 auth-admin.ghostnet.selfhost.eu"
|
||||
# GNMON-001 M6: monitoring dashboard via NPM (CT-103); mirrors the role default.
|
||||
- "10.0.0.10 mon.ghostnet.selfhost.eu"
|
||||
dns_pihole_timezone: Europe/Berlin
|
||||
dns_pihole_database_max_db_days: 30
|
||||
dns_pihole_secret_name: pihole_web_password
|
||||
|
||||
@@ -16,9 +16,12 @@ Environment=WEBPASSWORD_FILE={{ dns_pihole_secret_name }}
|
||||
Environment=TZ={{ dns_pihole_timezone }}
|
||||
Environment="FTLCONF_dns_upstreams={{ dns_pihole_upstreams | join(';') }}"
|
||||
Environment=FTLCONF_dns_listeningMode=LOCAL
|
||||
{% for record in dns_pihole_hosts_records %}
|
||||
Environment="FTLCONF_dns_hosts={{ record }}"
|
||||
{% endfor %}
|
||||
# One Environment line only: systemd keeps just the LAST assignment of a
|
||||
# duplicated key, so per-record lines would silently drop all but the last
|
||||
# record (Befund 09.11.2026: auth-admin fell through to upstream after the
|
||||
# second record was added). Pi-hole v6 takes list values semicolon-separated,
|
||||
# same as dns_upstreams above.
|
||||
Environment="FTLCONF_dns_hosts={{ dns_pihole_hosts_records | join(';') }}"
|
||||
Environment=FTLCONF_dhcp_active=false
|
||||
Environment=FTLCONF_ntp_ipv4_active=false
|
||||
Environment=FTLCONF_ntp_ipv6_active=false
|
||||
|
||||
Reference in New Issue
Block a user