Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Fix legacy impersonation system#46748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.4fromdunglas:fix/legacy-switch-user
Jun 23, 2022

Conversation

@dunglas
Copy link
Member

@dunglasdunglas commentedJun 23, 2022
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Ticketsn/a
LicenseMIT
Doc PRn/a

When using the legacy authentication system with a user class not
implementingEquatableInterface (for instance, the default when using
Sylius) a bug prevents the impersonation system from working properly.

The switch is done correctly, but then the user is disconnected on the
next request becauseSecurityContext::hasUserChanged() compares the
roles of the token in session with the roles of the temporary token, and they
aren't equal.

ROLE_PREVIOUS_ADMIN is added in
SwitchUserListener::attemptSwitchUser(), but then removed if the
legacy system is still enabled inUserAuthenticationProvider.

It looks like this bug has been introduced while deprecating support for
role classes:d64372d#diff-914ec544d4f7b26fda540aea3d7bc57cc5057d76bfb9ad72047d77739e3bb5a3L115

This patch fixes the issue (tested on a real Sylius project).

When using the legacy authentication system with a user class notimplementing `EquatableInterface` (for instance, the default when usingSylius) a bug prevents the impersonation system to work properly.The switch is done correctly, but then the user is disconnected on thenext request because `SecurityContext::hasUserChanged()` compares theroles of the token in session with the roles of the temporary token, and theyaren't equal.`ROLE_PREVIOUS_ADMIN` is added in`SwitchUserListener::attemptSwitchUser()`, but then removed if thelegacy system is still enabled in `UserAuthenticationProvider`.It looks like this bug has been introduced while deprecating support forrole classes:symfony@d64372d#diff-914ec544d4f7b26fda540aea3d7bc57cc5057d76bfb9ad72047d77739e3bb5a3L115This patch fixes the issue (tested on a real Sylius project).
Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

LGTM

@fabpot
Copy link
Member

Thank you@dunglas.

@fabpotfabpot merged commitb3c1841 intosymfony:5.4Jun 23, 2022
@dunglasdunglas deleted the fix/legacy-switch-user branchJune 23, 2022 13:18
This was referencedJun 26, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@stofstofstof approved these changes

@chalasrchalasrchalasr approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuh

@wouterjwouterjAwaiting requested review from wouterj

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

5 participants

@dunglas@fabpot@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp