Skip to content

[6.x] Fix enforced two factor setup elevation - #15329

Merged
jasonvarga merged 3 commits into
6.xfrom
15216
Sep 22, 2026
Merged

jasonvarga merged 3 commits into
6.xfrom
15216

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Sep 1, 2026

Copy link
Copy Markdown
Member

This pull request fixes an issue where users with enforced two-factor authentication cannot start setup when their session is not elevated.

This was happening because the enforced-setup middleware redirected the elevation endpoints, and the outside layout did not render the elevation dialog.

This PR fixes it by allowing the elevation flow during setup, rendering its dialog, surfacing setup errors, and allowing admins to clear incomplete setup.

Fixes #15216

@jasonvarga jasonvarga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix itself is right, and I traced the whole flow — requireElevatedSession()GET /cp/elevated-session → the appended modal → POST /cp/elevated-sessionPOST /cp/two-factor/enable — and it works end to end. The two new tests are genuine guards too: with two_factor_enforced_roles => ['*'] and a user that fails hasEnabledTwoFactorAuthentication(), both would 302 rather than 200 without the route change.

One thing to change before this goes in — the middleware exemption is wider than the fix needs. Details inline.

Comment thread routes/cp.php Outdated
duncanmcclean and others added 2 commits September 22, 2026 15:27
Only the JSON elevation endpoints need to skip
`RedirectIfTwoFactorSetupIncomplete`. The confirm password page renders
the full control panel layout, so exempting it let users with incomplete
enforced two factor setup see the nav.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jasonvarga
jasonvarga enabled auto-merge (squash) September 22, 2026 15:16
@jasonvarga
jasonvarga disabled auto-merge September 22, 2026 15:18
@jasonvarga
jasonvarga merged commit cb01754 into 6.x Sep 22, 2026
64 checks passed
@jasonvarga
jasonvarga deleted the 15216 branch September 22, 2026 15:18
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.

Enforced 2FA setup dead-ends when the session is not elevated — dialog swallows the 403

2 participants