fix(caddy,authentik): auth guarded vhosts by proxying the whole request through authentik

The forward_auth target /outpost.goauthentik.io/auth/caddy does not exist
in authentik 2026.8 (verified live: 404 for every header combination; the
URL tree has no outpost auth prefix at all — the outpost worker dials back
to core over ws/outpost/<uuid>/ instead). Unauthenticated subrequests got
404, Caddy treated >=400 as 'not authenticated' and redirected browsers to
the dead path — users saw authentik's own Not-Found page.

Fix: guarded vhosts now proxy the whole request through authentik-server:9000
with X-authentik-meta-outpost/-provider/-app headers (the exact header set
this build's Traefik controller emits, adapted for Caddy). Unauthenticated
clients get the login flow served in place; once a session exists,
authentik proxies on to the provider's internal_host — now
http://caddy:8017, a new post-auth internal listener that routes straight to
the app. The chain terminates; nothing dials back into authentik.

Live DB changes applied alongside (postgres is the source of truth):
provider pk=1 authentication_flow=default-authentication-flow (was NULL —
the actual cause of the 404s) and internal_host=http://caddy:8017 (was
self-referential http://authentik-server:9000).
This commit is contained in:
Frank committed 2026-08-28 22:28:32 -07:00
1 parent 3a16375cfe
commit ef07e7d01a
5 files changed
+153 -141

No files matched your search

+5 -3
View File
@@ -37,9 +37,11 @@ setup() {
local block
block=$(awk '/^franksdank\.cloud[[:space:]]/,/^}/' "$CADDY")
echo "$block" | grep -q 'reverse_proxy anubis:8923'
# The SSO check itself now runs on the internal listener that Anubis
# The SSO check itself runs on the internal listener that Anubis
# forwards accepted traffic to; Host survives the hop, so per-vhost
# routing (and with it forward_auth) resumes there.
# routing resumes there — guarded vhosts proxy the whole request
# through Authentik, which forwards authenticated traffic back on the
# post-auth listener (http://:8017) that routes straight to the app.
grep -q 'http://:8016' "$CADDY"
awk '/^http:\/\/:8016/,/^\}/' "$CADDY" | grep -q 'forward_auth authentik-server:9000'
awk '/^http:\/\/:8016/,/^\}/' "$CADDY" | grep -q 'reverse_proxy authentik-server:9000'
}