Repository navigation
outposts/proxy: honor X-Forwarded-Host in envoy forward auth - #26888
Conversation
The envoy handler built the post-login redirect from the raw Host header, while the outpost picks the application with the ak-axum Host extractor, which uses X-Forwarded-Host from trusted proxies. When a front proxy rewrote :authority to an internal name, users landed on that internal host after login. The Go outpost replaced the host with X-Forwarded-Host for trusted proxies, so this broke in the Rust rewrite. Use the same extractor for the redirect target. Untrusted peers still cannot pick the redirect host. Closes: #26867
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26888 +/- ##
==========================================
+ Coverage 92.48% 92.57% +0.09%
==========================================
Files 1197 1197
Lines 81116 81176 +60
Branches 4497 4557 +60
==========================================
+ Hits 75017 75151 +134
+ Misses 6033 5949 -84
- Partials 66 76 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Playwright e2eDownload this run's HTML report and traces, then open the report: gh run download 40803390027 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-reportInstallation instructionsInstructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-5dd200cbb9a43e64326a05392eef1ae4443e960d
# Distroless image: AUTHENTIK_TAG=gh-5dd200cbb9a43e64326a05392eef1ae4443e960d-distroless
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-5dd200cbb9a43e64326a05392eef1ae4443e960d
# Distroless image: tag: gh-5dd200cbb9a43e64326a05392eef1ae4443e960d-distrolessAfterwards, run the upgrade commands from the latest release notes. |
The envoy_forward_target unit tests pass a host string directly, so they still pass if handle_envoy goes back to reading the raw Host header. Drive the handler through host_middleware with a trusted proxy instead. The untrusted-peer case stays out because ak-axum's Host extractor tests already cover it.
|
🍒 Cherry-pick to |
* main: (114 commits) website/integrations: add planka sso requirement note (#27376) core: bump ruff from 0.17.2 to 0.17.3 (#27370) core: bump cachetools from 7.2.5 to 7.2.6 (#27372) core: bump coverage[toml] from 7.16.2 to 7.17.0 (#27373) core: bump django from 5.2.17 to 5.2.18 (#27369) core: bump google-api-core from 2.36.0 to v2.43.0 (#27214) core: bump boto3 from 1.43.90 to v1.43.119 (#27208) core: bump googleapis-common-protos from 1.75.3 to v1.76.0 (#27217) core: bump msgpack from 1.2.3 to v1.2.4 (#27235) packages/django-dramatiq-postgres: limit task fetching (#27197) web/admin: make flow execute links base-path aware (#27314) lib: fix capture_logs not thread safe (#27355) web/user: keep configure URL query strings when adding next (#27313) web/flow: refresh WebAuthn challenge on authentication retry (#26616) server, lifecycle: drop idle upstream connections before uvicorn does (#27192) outposts: only write changed permissions, add endpoint to rebuild them (#26928) flows: fix planner not resolving stages causing extra queries (#27320) outposts/proxy: honor X-Forwarded-Host in envoy forward auth (#26888) website/docs: Update wording for internal and external users (#27345) server: strip hop-by-hop headers before forwarding to the application (#27191) ...
* main: (115 commits) lib/tracing: use BatchSpanProcessor (#27387) website/integrations: add planka sso requirement note (#27376) core: bump ruff from 0.17.2 to 0.17.3 (#27370) core: bump cachetools from 7.2.5 to 7.2.6 (#27372) core: bump coverage[toml] from 7.16.2 to 7.17.0 (#27373) core: bump django from 5.2.17 to 5.2.18 (#27369) core: bump google-api-core from 2.36.0 to v2.43.0 (#27214) core: bump boto3 from 1.43.90 to v1.43.119 (#27208) core: bump googleapis-common-protos from 1.75.3 to v1.76.0 (#27217) core: bump msgpack from 1.2.3 to v1.2.4 (#27235) packages/django-dramatiq-postgres: limit task fetching (#27197) web/admin: make flow execute links base-path aware (#27314) lib: fix capture_logs not thread safe (#27355) web/user: keep configure URL query strings when adding next (#27313) web/flow: refresh WebAuthn challenge on authentication retry (#26616) server, lifecycle: drop idle upstream connections before uvicorn does (#27192) outposts: only write changed permissions, add endpoint to rebuild them (#26928) flows: fix planner not resolving stages causing extra queries (#27320) outposts/proxy: honor X-Forwarded-Host in envoy forward auth (#26888) website/docs: Update wording for internal and external users (#27345) ...
…pick #26888 to version-2026.8) (#27351) outposts/proxy: honor X-Forwarded-Host in envoy forward auth (#26888) * outposts/proxy: honor X-Forwarded-Host in envoy forward auth The envoy handler built the post-login redirect from the raw Host header, while the outpost picks the application with the ak-axum Host extractor, which uses X-Forwarded-Host from trusted proxies. When a front proxy rewrote :authority to an internal name, users landed on that internal host after login. The Go outpost replaced the host with X-Forwarded-Host for trusted proxies, so this broke in the Rust rewrite. Use the same extractor for the redirect target. Untrusted peers still cannot pick the redirect host. Closes: #26867 * outposts/proxy: drop envoy handler tests that repeat ak-axum coverage * outposts/proxy: test that envoy forward auth uses the forwarded host The envoy_forward_target unit tests pass a host string directly, so they still pass if handle_envoy goes back to reading the raw Host header. Drive the handler through host_middleware with a trusted proxy instead. The untrusted-peer case stays out because ak-axum's Host extractor tests already cover it. Co-authored-by: Dominic Roy <[email protected]>
Details
What does this PR change?
The Envoy forward auth endpoint now builds the post-login redirect from the same host the outpost uses to pick the application. That host is
X-Forwarded-Hostwhen the request comes from a trusted proxy (listen.trusted_proxy_cidrs), andHostotherwise. A client outside the trusted ranges still can't choose where it gets redirected.This also applies to standalone proxy outposts, not only the embedded one. The Go standalone outpost always used the raw
Hostfor this redirect, though it already usedX-Forwarded-Hostto pick the application.Why is this change needed?
Since the Rust rewrite in 2026.8.0, the Envoy handler read the raw
Hostheader. If a front proxy setsX-Forwarded-Host: app.example.comand rewrites:authoritytoapp.internal.examplebefore Envoy, the outpost picked the right application but sent the user to//app.internal.example/...after login. The Go embedded outpost ran behindProxyHeaders, which replaced the host withX-Forwarded-Hostfor trusted proxies, so this worked on 2026.5.The removed
400 invalid envoy requestbranch was only reachable without a host. The host middleware already rejects that case with a 400.How was this tested?
Updated the
envoy_forward_targetunit tests for the new signature. The trusted and untrustedX-Forwarded-Hosthandling is already covered by the ak-axumHostextractor tests. I didn't test against a real Envoy or Istio.Linked issues
Closes #26867
Checklist
make all)make docs)