lab.cloonar.com: replace Authelia forward-auth with a LAN/WireGuard restriction #285
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos#285
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #266.
lab.cloonar.comis the last consumer of Authelia's forward-auth. Replace theauth_requestgate with a source-address restriction plus a fixedRemote-User, so Authelia can be retired without introducing oauth2-proxy.Why this instead of oauth2-proxy
ADR-0022's M5 planned oauth2-proxy for the
auth_requestvhosts. That plan is superseded: Zammad has been retired,typo3's/autheliablock was always dead code (internal;, noauth_requestconsumer), andmcp-forgejois being dropped.lab.cloonar.comis the only one left, and standing up a new component plus a seventh Keycloak client plus two secrets — one of them duplicated across two hosts' sops files — to gate a single vhost is not worth it.coding-lab has no OIDC support: its only auth paths are its own web sessions and the
Remote-Userproxy header fromtrustedProxies. So it cannot become a Keycloak client directly either.Scope —
hosts/fw/vms/web/lab.nixonlyRemove:
location /autheliablock inextraConfigauth_request /authelia;auth_request_set $target_url …;anderror_page 401 =302 https://auth.cloonar.com/?rd=$target_url;auth_request_set $lab_remote_user $upstream_http_remote_user;Add, in
locations."/":Use
config.networkPrefixrather than hardcoding10.42, matching the file's existing style.Change:
proxy_set_header Remote-User dominik.polakovics@cloonar.com;— a literal, replacing the value previously taken from Authelia's response.That value is not arbitrary: it must equal coding-lab's admin username exactly, or
resolveProxyHeaderfinds no user and silently falls through to the login form. It is also precisely what Authelia was already sending, sinceauthelia.nix:74setsusername_attribute = "mail".Preserve
Host/X-Real-IP/X-Forwarded-Protohere.recommendedProxySettingsalready injects them, nginx accumulatesproxy_set_header, and coding-lab's Go server rejects duplicateHostwith a bare400before any handler runs. This has broken the vhost before./api/v1/events— no buffering, no read timeout.Why the allow-list is correct, and what would break it
lab.cloonar.comresolves to fw's public address even from inside, so internal clients arrive via the hairpin DNAT atfirewall.nix:187. The source address survives it — walking the postrouting chain, traffic to.97.5matches no masquerade rule: it leaves viaserver(notwan/wg_cloonar),.97.5is absent from theiifname { wan, wg_cloonar } ip daddr …list, andiifname "server" oifname "server"excludes clients arriving onlanorwg_cloonar. So nginx sees10.42.96.x,10.42.98.x, or the real public address.Record both dependencies as comments, because each fails silently:
.97.5to those masquerade destination lists would make every request appear to come from fw.set_real_ip_from/real_ip_header, so$remote_addris the true TCP peer and the allow-list cannot be spoofed viaX-Forwarded-For. Enabling the real_ip module on this host later would turn the allow-list into an attacker-controlled header check.Trust model change — state it in the commit message
The gate moves from "authenticated Authelia session in
Administrators/Mitarbeiter" to "anywhere on the LAN or the VPN". Any device on10.42.96.0/24— guest laptops, phones, IoT — is nowdominik.polakovics@cloonar.comin coding-lab, with no login. coding-lab can launch AFK agents that commit to the repositories, so this is a deliberate trade of authentication for network isolation, not an oversight.ADR
Amend
docs/adr/0022-keycloak-and-scoped-kerberos.md: M5 no longer introduces oauth2-proxy. Record why — Zammad retired, typo3 dead, mcp-forgejo dropped, coding-lab has no OIDC — and the trust-model change above. Note the consequence for the Keycloak-vs-authentik comparison: the oauth2-proxy workstream the ADR counted as Keycloak's price never had to be paid, so that argument reads differently in hindsight.Out of scope
authelia.nix, including the now-unusedlab.cloonar.comaccess_controlrule.Verification
scripts/pre-commitdry-builds the affected hosts.Human, after deploy:
https://lab.cloonar.comloads and you are already logged in — no login form. A login form means theRemote-Uservalue doesn't match coding-lab's admin username.nbover WireGuard: same.403.10.42.96.x/10.42.98.x), not fw's address — this is the hairpin assumption above, and it is the one thing worth seeing rather than trusting.Rollback is reverting the commit; Authelia is still running and its
lab.cloonar.comrule is untouched.