Skip to content

[6.x] Skip two factor setup enforcement while impersonating - #15247

Open
duncanmcclean wants to merge 4 commits into
6.xfrom
impersonation-two-factor-setup
Open

[6.x] Skip two factor setup enforcement while impersonating#15247
duncanmcclean wants to merge 4 commits into
6.xfrom
impersonation-two-factor-setup

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where impersonating a user who hasn't set up two factor authentication (when it's enforced for their role) would redirect the impersonator to that user's 2FA setup screen, persisting a two_factor_secret and two_factor_recovery_codes onto the impersonated user's record in the process. Abandoning the setup didn't roll this back, and the impersonator could even complete the enrollment on the user's behalf.

This was happening because the RedirectIfTwoFactorSetupIncomplete middleware generates and saves a secret as a side effect of redirecting to the setup screen, and it didn't account for impersonation. Impersonation already bypasses the 2FA challenge, but not setup enforcement, which was inconsistent.

This PR fixes it by skipping the setup enforcement while impersonating, so the impersonator is never sent to the setup screen and nothing is written to the impersonated user's record. Enforcement kicks in as normal when the user next logs in themselves.

Fixes #15231

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.

Impersonating a user who has never completed 2FA setup writes two_factor_secret and two_factor_recovery_codes to that user's record

1 participant