fix(mars): trust only neptun's proxy for the Hermes dashboard
Replaces FORWARDED_ALLOW_IPS="*" with dashboard.trusted_proxies pinned to neptun's tailnet IP (merged into config.yaml by prepare-dirs via yq) and pins HERMES_DASHBOARD_PUBLIC_URL so the OIDC redirect_uri stays https. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,10 @@ let
|
|||||||
# is hers to make, anywhere inside HERMES_WRITE_SAFE_ROOT=/opt/data.
|
# is hers to make, anywhere inside HERMES_WRITE_SAFE_ROOT=/opt/data.
|
||||||
giteaHost = "git.mgaction.town";
|
giteaHost = "git.mgaction.town";
|
||||||
|
|
||||||
|
# neptun's tailnet IP: its Caddy is the only proxy whose X-Forwarded-Proto
|
||||||
|
# the dashboard should trust.
|
||||||
|
neptunTailnetIp = "100.64.0.5";
|
||||||
|
|
||||||
# luna's webhook filters, mounted READ-ONLY from the nix store rather than
|
# luna's webhook filters, mounted READ-ONLY from the nix store rather than
|
||||||
# written into hermesHome: that IS her write-safe root, so a writable copy
|
# written into hermesHome: that IS her write-safe root, so a writable copy
|
||||||
# would let her edit her own loop guard back out. A missing script fails
|
# would let her edit her own loop guard back out. A missing script fails
|
||||||
@@ -139,7 +143,7 @@ in
|
|||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
unitConfig.RequiresMountsFor = [ "/mnt/jupiter" ];
|
unitConfig.RequiresMountsFor = [ "/mnt/jupiter" ];
|
||||||
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils ];
|
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils pkgs.yq-go ];
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
# Everything here is either local or bounded to ~30s by the probe loop, so
|
# Everything here is either local or bounded to ~30s by the probe loop, so
|
||||||
# anything past two minutes is a hang, not slowness.
|
# anything past two minutes is a hang, not slowness.
|
||||||
@@ -210,6 +214,15 @@ in
|
|||||||
# scripts as uid ${hermesUid}.
|
# scripts as uid ${hermesUid}.
|
||||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/scripts
|
chown ${hermesUid}:${hermesGid} ${hermesHome}/scripts
|
||||||
|
|
||||||
|
# trusted_proxies has no env override and Hermes owns config.yaml, so
|
||||||
|
# only this key is merged in; without it the Secure cookie flag breaks.
|
||||||
|
conf=${hermesHome}/config.yaml
|
||||||
|
[ -e "$conf" ] || : > "$conf"
|
||||||
|
yq '.dashboard.trusted_proxies = ["${neptunTailnetIp}"]' "$conf" > "$conf.new"
|
||||||
|
chown ${hermesUid}:${hermesGid} "$conf.new"
|
||||||
|
chmod --reference="$conf" "$conf.new"
|
||||||
|
mv -f "$conf.new" "$conf"
|
||||||
|
|
||||||
if [ -d ${hermesHome}/.config ]; then
|
if [ -d ${hermesHome}/.config ]; then
|
||||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
||||||
fi
|
fi
|
||||||
@@ -268,12 +281,9 @@ in
|
|||||||
HERMES_DASHBOARD_HOST = "0.0.0.0"; # must be tailscale0-reachable, not just loopback
|
HERMES_DASHBOARD_HOST = "0.0.0.0"; # must be tailscale0-reachable, not just loopback
|
||||||
HERMES_DASHBOARD_OIDC_ISSUER = "https://auth.mgaction.town/application/o/hermes/";
|
HERMES_DASHBOARD_OIDC_ISSUER = "https://auth.mgaction.town/application/o/hermes/";
|
||||||
HERMES_DASHBOARD_OIDC_CLIENT_ID = "4BqdJu3htnMtSZnyEu5zHnsSOvlEbw3Ie3mYVlh6";
|
HERMES_DASHBOARD_OIDC_CLIENT_ID = "4BqdJu3htnMtSZnyEu5zHnsSOvlEbw3Ie3mYVlh6";
|
||||||
# uvicorn only trusts X-Forwarded-Proto from forwarded_allow_ips
|
# Pins the OIDC redirect_uri to https; otherwise it is rebuilt from
|
||||||
# (default 127.0.0.1); neptun's Caddy reaches this over a real routed
|
# forwarded headers (see trusted_proxies in prepare-dirs).
|
||||||
# tailnet IP, so without this it builds an http:// redirect_uri that
|
HERMES_DASHBOARD_PUBLIC_URL = "https://hermes.mgaction.town";
|
||||||
# Authentik rejects. Safe to trust any peer: 9119 is already scoped to
|
|
||||||
# loopback + tailscale0 only.
|
|
||||||
FORWARDED_ALLOW_IPS = "*";
|
|
||||||
};
|
};
|
||||||
environmentFiles = [ config.sops.templates."hermes-agent.env".path ];
|
environmentFiles = [ config.sops.templates."hermes-agent.env".path ];
|
||||||
cmd = [ "gateway" "run" ];
|
cmd = [ "gateway" "run" ];
|
||||||
|
|||||||
Reference in New Issue
Block a user