Skip to content

outpost/proxyv2: revalidate auth if session fails to load#18063

Merged
dewi-tik merged 1 commit intogoauthentik:mainfrom
chetan:fix/fwd-auth-revalidate
Feb 5, 2026
Merged

outpost/proxyv2: revalidate auth if session fails to load#18063
dewi-tik merged 1 commit intogoauthentik:mainfrom
chetan:fix/fwd-auth-revalidate

Conversation

@chetan
Copy link
Contributor

@chetan chetan commented Nov 11, 2025

Bug

The forward auth handler in the outpost does not properly handle a session load failure. When the session fails to load, it simply bails out, returning a 200 to the reverse proxy which then allows the request to proceed. Depending on the configuration of the upstream service, this can result in a 401, basic auth prompt, or simply allowing access. With one of my applications, the app set it's own cookies which still granted access despite the invalid authentik session.

Similar issue is mentioned in #2023 (comment)

Setup:

Flow:

  1. Visit https://app.example.com -> redir to auth, sign in -> redir to app
  2. Visit https://auth.example.com -> sign out
  3. Session is properly invalidated at the outpost, e.g.:
{"event":"Logging out","level":"debug","logger":"authentik.outpost.proxyv2","provider":"app.example.com","timestamp":"2025-11-10T17:22:54Z"}
{"event":"deleting session","level":"trace","logger":"authentik.outpost.proxyv2.application","name":"provider-app","path":"/dev/shm/session_6JCRTWRRAVWIPWGLBIWZZPLTYUI27PYAVIEQKH5YSDQOMBNMMIWA","timestamp":"2025-11-10T17:22:54Z"}
  1. Visit https://app.example.com - warning logged but fwd auth returns 200 - app returns 401

Step 2 can also be a restart of the outpost due to crash, reboot, or redeployment.

Fix

After session validation falls through, fix the session/state setup so we can redirect to the auth server and complete the flow. User will either be prompted to log in or, if they had already logged back in again, they will be sent back and the new session will be established properly.

@netlify
Copy link

netlify bot commented Nov 11, 2025

Deploy Preview for authentik-docs canceled.

Name Link
🔨 Latest commit cb47b17
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/69161a286162040008b9b54c

@netlify
Copy link

netlify bot commented Nov 11, 2025

Deploy Preview for authentik-integrations canceled.

Name Link
🔨 Latest commit cb47b17
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/69161a281d2d7a000815d49c

@netlify
Copy link

netlify bot commented Nov 11, 2025

Deploy Preview for authentik-storybook canceled.

Name Link
🔨 Latest commit cb47b17
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/69161a280819e2000862b2b5

@BeryJu BeryJu requested a review from dominic-r November 11, 2025 15:53
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.23%. Comparing base (e90c249) to head (91e2829).
⚠️ Report is 96 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18063      +/-   ##
==========================================
- Coverage   93.24%   93.23%   -0.01%     
==========================================
  Files         968      968              
  Lines       53331    53331              
==========================================
- Hits        49726    49722       -4     
- Misses       3605     3609       +4     
Flag Coverage Δ
conformance 38.07% <ø> (+<0.01%) ⬆️
e2e 44.08% <ø> (+<0.01%) ⬆️
integration 22.87% <ø> (-0.06%) ⬇️
unit 91.41% <ø> (+<0.01%) ⬆️
unit-migrate 91.46% <ø> (+0.05%) ⬆️

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

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

Copy link
Member

@dominic-r dominic-r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@rissson rissson moved this from Todo to In review in authentik Core Nov 12, 2025
@rissson rissson added this to the Release 2025.10.2 milestone Nov 12, 2025
Copy link
Member

@dominic-r dominic-r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@github-project-automation github-project-automation bot moved this from In review to In Progress in authentik Core Nov 13, 2025
@chetan chetan force-pushed the fix/fwd-auth-revalidate branch 2 times, most recently from e161e40 to cb47b17 Compare November 13, 2025 17:49
@rissson rissson added area:backend backport/version-2025.10 Add this label to PRs to backport changes to version-2025.10 labels Dec 10, 2025
@rissson rissson moved this from In Progress to Needs review in authentik Core Dec 10, 2025
@dewi-tik
Copy link
Contributor

Closes #19740

@dominic-r dominic-r added the backport/version-2025.12 Add this label to PRs to backport changes to version-2025.12 label Jan 29, 2026
@chetan chetan force-pushed the fix/fwd-auth-revalidate branch from cb47b17 to 91e2829 Compare January 30, 2026 16:00
@chetan
Copy link
Contributor Author

chetan commented Jan 30, 2026

Rebased/resolved conflict

@github-project-automation github-project-automation bot moved this from Needs review to In Progress in authentik Core Feb 5, 2026
@dewi-tik dewi-tik moved this from In Progress to In review in authentik Core Feb 5, 2026
@dewi-tik dewi-tik merged commit 3f1a0f8 into goauthentik:main Feb 5, 2026
142 of 144 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in authentik Core Feb 5, 2026
@authentik-automation
Copy link
Contributor

🍒 Cherry-pick to version-2025.10 created: #20058

@authentik-automation
Copy link
Contributor

🍒 Cherry-pick to version-2025.12 created: #20059

@dewi-tik
Copy link
Contributor

dewi-tik commented Feb 5, 2026

Thanks for this @chetan !

BeryJu pushed a commit that referenced this pull request Feb 5, 2026
…#18063 to version-2025.12) (#20059)

outpost/proxyv2: revalidate auth if session fails to load (#18063)

Co-authored-by: Chetan Sarva <chetan@pixelcop.net>
Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
BeryJu pushed a commit that referenced this pull request Feb 5, 2026
…#18063 to version-2025.10) (#20058)

outpost/proxyv2: revalidate auth if session fails to load (#18063)

Co-authored-by: Chetan Sarva <chetan@pixelcop.net>
Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
atereshkin pushed a commit to atereshkin/authentik that referenced this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants