Skip to content

outposts/proxy: honor X-Forwarded-Host in envoy forward auth - #26888

Merged
dominic-r merged 6 commits into
mainfrom
dominic/proxy-envoy-forwarded-host
Oct 29, 2026
Merged

dominic-r merged 6 commits into
mainfrom
dominic/proxy-envoy-forwarded-host

Conversation

@dominic-r

@dominic-r dominic-r commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

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-Host when the request comes from a trusted proxy (listen.trusted_proxy_cidrs), and Host otherwise. 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 Host for this redirect, though it already used X-Forwarded-Host to pick the application.

Why is this change needed?

Since the Rust rewrite in 2026.8.0, the Envoy handler read the raw Host header. If a front proxy sets X-Forwarded-Host: app.example.com and rewrites :authority to app.internal.example before Envoy, the outpost picked the right application but sent the user to //app.internal.example/... after login. The Go embedded outpost ran behind ProxyHeaders, which replaced the host with X-Forwarded-Host for trusted proxies, so this worked on 2026.5.

The removed 400 invalid envoy request branch was only reachable without a host. The host middleware already rejects that case with a 400.

How was this tested?

Updated the envoy_forward_target unit tests for the new signature. The trusted and untrusted X-Forwarded-Host handling is already covered by the ak-axum Host extractor tests. I didn't test against a real Envoy or Istio.

Linked issues

Closes #26867


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

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
@dominic-r
dominic-r requested a review from a team as a code owner October 13, 2026 15:42
@dominic-r dominic-r added area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 labels Oct 13, 2026
@dominic-r dominic-r self-assigned this Oct 13, 2026
@dominic-r
dominic-r requested a review from rissson October 13, 2026 15:42
@netlify

netlify Bot commented Oct 13, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 0bcfd86
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6ace516b62e94786dbd2c5fc
😎 Deploy Preview https://deploy-preview-26888--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dominic-r
dominic-r removed the request for review from rissson October 13, 2026 15:46
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.57%. Comparing base (98c4b28) to head (5dd200c).
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ
conformance 31.15% <ø> (+<0.01%) ⬆️
e2e 36.01% <ø> (+<0.01%) ⬆️
integration 28.62% <ø> (+<0.01%) ⬆️
rust 48.29% <100.00%> (+2.31%) ⬆️
unit 94.13% <ø> (+<0.01%) ⬆️
unit-migrate 94.12% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Playwright e2e

Download 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-report

Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

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)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

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-distroless

Afterwards, run the upgrade commands from the latest release notes.

@BeryJu
BeryJu requested a review from rissson October 15, 2026 14:47
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.
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Oct 29, 2026
@dominic-r
dominic-r merged commit 0dc918d into main Oct 29, 2026
171 checks passed
@dominic-r
dominic-r deleted the dominic/proxy-envoy-forwarded-host branch October 29, 2026 15:54
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Oct 29, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #27351

kensternberg-authentik added a commit that referenced this pull request Oct 30, 2026
* 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)
  ...
kensternberg-authentik added a commit that referenced this pull request Oct 30, 2026
* 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)
  ...
dominic-r added a commit that referenced this pull request Nov 23, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

outposts/proxy: envoy forward auth uses Host instead of X-Forwarded-Host since 2026.8.0

2 participants