Skip to content

flows: strip login_hint from next on cancel to prevent loop - #26111

Merged
BeryJu merged 3 commits into
goauthentik:mainfrom
Jorge-Polanco-Roque:fix/login-hint-not-you-loop-25476
Sep 15, 2026
Merged

BeryJu merged 3 commits into
goauthentik:mainfrom
Jorge-Polanco-Roque:fix/login-hint-not-you-loop-25476

Conversation

@Jorge-Polanco-Roque

Copy link
Copy Markdown
Contributor

Closes #25476.

login_hint rides along in the next param, so hitting "Not You?" just re-prefills the same email and reloads — an infinite loop.

The chain: authorize redirects to the flow with next=<authorize URL incl. login_hint>; the identification stage prefills from it (correct on first arrival); but "Not You?" points at the cancel URL whose next still carries login_hint, so CancelView redirects straight back into authorize and re-prefills.

CancelView is the single point where the user expresses "change identity", and every provider's next routes through it — so that's the minimal root-cause fix: strip only login_hint from the next URL there (preserving client_id, state, etc.). The legitimate first-arrival prefill is untouched.

Tests: test_cancel_strips_login_hint (login_hint gone after cancel, other params kept) and test_cancel_preserves_next_without_login_hint; both fail without the fix. The existing test_login_hint (first-arrival prefill) still passes. ruff is clean.

Note: I couldn't run the full pytest suite locally (needs the multi-tenant Postgres + xmlsec1 setup) — a CI run would be good to confirm.


Disclosure: I use AI assistance for code review and for drafting text; I review and verify every change myself.

When a login_hint is passed to the OAuth2 authorize endpoint, it is prefilled
into the identification stage and also carried in the flow's `next` param. On
clicking 'Not You?', CancelView redirected back to `next`, which re-entered the
authorize flow and re-applied login_hint from the URL, trapping the user in a
loop.

Strip login_hint from the cancel `next` redirect so re-entering the flow no
longer re-prefills the identifier, while legitimate first-arrival prefill (read
directly from the authorize URL) is unaffected.

Fixes goauthentik#25476
@Jorge-Polanco-Roque
Jorge-Polanco-Roque requested a review from a team as a code owner September 14, 2026 01:56
@netlify

netlify Bot commented Sep 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 7e705ff
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6aa7545df05cd5000953cef0
😎 Deploy Preview https://deploy-preview-26111--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.

@BeryJu BeryJu changed the title fix(flows): strip login_hint from next on cancel to prevent 'Not You?' loop flows: strip login_hint from next on cancel to prevent loop Sep 14, 2026
Signed-off-by: Jens Langhammer <[email protected]>
@BeryJu BeryJu added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Sep 14, 2026
@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.86%. Comparing base (31adac9) to head (74d299d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26111      +/-   ##
==========================================
- Coverage   91.89%   91.86%   -0.03%     
==========================================
  Files        1171     1171              
  Lines       75653    75679      +26     
  Branches     4056     4056              
==========================================
+ Hits        69521    69524       +3     
- Misses       6090     6113      +23     
  Partials       42       42              
Flag Coverage Δ
conformance 33.68% <10.71%> (-0.01%) ⬇️
e2e 38.35% <10.71%> (-0.01%) ⬇️
integration 29.95% <10.71%> (-0.46%) ⬇️
rust 42.89% <ø> (ø)
unit 93.46% <100.00%> (+<0.01%) ⬆️
unit-migrate 93.48% <100.00%> (+<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.

if next_url and not is_url_absolute(next_url):
return redirect(next_url)
# Ensure that we get rid of any user identifiers from the URL
return redirect(self.clean_next_url(next_url))
@BeryJu
BeryJu merged commit 0e9a19a into goauthentik:main Sep 15, 2026
137 of 138 checks passed
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

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

BeryJu added a commit that referenced this pull request Sep 15, 2026
…ick #26111 to version-2026.8) (#26168)

flows: strip login_hint from next on cancel to prevent loop (#26111)

* flows: clear login_hint on cancel to fix 'Not You?' loop

When a login_hint is passed to the OAuth2 authorize endpoint, it is prefilled
into the identification stage and also carried in the flow's `next` param. On
clicking 'Not You?', CancelView redirected back to `next`, which re-entered the
authorize flow and re-applied login_hint from the URL, trapping the user in a
loop.

Strip login_hint from the cancel `next` redirect so re-entering the flow no
longer re-prefills the identifier, while legitimate first-arrival prefill (read
directly from the authorize URL) is unaffected.

Fixes #25476

* cleanup



---------

Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Jorge Polanco <[email protected]>
Co-authored-by: Jens Langhammer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

login_hint causes "Not You?" loop

3 participants