Skip to content

Ask for the second factor instead of looping between / and /login - #10

Merged
bulbashenko merged 1 commit into
mainfrom
fix/aal2-redirect-loop
Oct 11, 2026
Merged

bulbashenko merged 1 commit into
mainfrom
fix/aal2-redirect-loop

Conversation

@bulbashenko

Copy link
Copy Markdown
Collaborator

With the password accepted but the second factor pending (an aal1 session), opening / or any return_to looped until the browser gave up with ERR_TOO_MANY_REDIRECTS:

  1. /: toSession is 403 (highest_available wants aal2), so it redirects to /login.
  2. /login without a flow goes to /self-service/login/browser without aal=aal2.
  3. Kratos sees a session, answers "already logged in" and redirects to return_to (by default /).

A fresh login flow now asks for aal=aal2 when whoami answers session_aal2_required. The e2e test opens / and /login from the 2FA screen. It fails with ERR_TOO_MANY_REDIRECTS on the old code; with the fix all 16 e2e tests pass locally.

🤖 Generated with Claude Code

With the password accepted but the second factor still pending, the session is
aal1. Opening / (or any return_to) then looped until the browser gave up with
ERR_TOO_MANY_REDIRECTS:

  /       toSession is 403 (highest_available wants aal2) → /login
  /login  no flow → /self-service/login/browser, without aal=aal2
  Kratos  a session exists → "already logged in" → return_to, by default /

It happened whenever someone left the 2FA screen, reopened the portal or an
app, or the 2FA flow expired (Kratos sends the browser to /login?flow=<id>, so
a restarted flow had no aal=aal2 either). A fresh login flow now asks Kratos
for aal2 when whoami answers session_aal2_required.

The e2e test reproduces the loop on the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bulbashenko
bulbashenko merged commit a038189 into main Oct 11, 2026
2 checks passed
@bulbashenko
bulbashenko deleted the fix/aal2-redirect-loop branch October 11, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant