-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Can't login manually with multiple roles #35509
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You should not do anything with the user token in the session directly, let the security component handle this. Perhaps this can help you? https://symfonycasts.com/screencast/symfony-security/registration-auth |
I saw this solution, but looks like I need to mix admin and user roles on a fly, without saving roles to database. So permissions must stores only in a session. Your example load user from a db. |
Have you tried this feature? https://symfony.com/doc/current/security/impersonating_user.html |
Thanks, this is helpful. |
It is because of compare roles update in abstractToken class 4f4c30d.
|
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Security] Fixed AbstractToken::hasUserChanged() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36989 | License | MIT | Doc PR | - This PR completely reverts #35944. That PR tried to fix a BC break (ref #35941, #35509) introduced by #31177. However, this broke many authentications (ref #36989), as the User is serialized in the session (as hinted by @stof). Many applications don't include the `roles` property in the serialization (at least, the MakerBundle doesn't include it). In 5.2, we should probably deprecate having different roles in token and user, which fixes the BC breaks all together. Commits ------- f297beb [Security] Fixed AbstractToken::hasUserChanged()
Yesterday my project moved from 4.3.4 to 4.4.3 and I got a problem.
I have a piece of code that allows to login as other user without sign out. So admin can login with ROLE_ADMIN first and then login as user and have roles: ROLE_ADMIN, ROLE_OWNER, ROLE_USER. In result admin will have permissions of admin and user. He can view admin and user pages at the same time.
Listing:
And everything worked until I did upgrade. Now nothing happens after this action. Just redirection without saving of new roles in a session.
Also, I notices that if do not merge roles, and give just user roles(without ROLE_ADMIN) authentication will work, but now admin will lost admin permissions and logout will be required.
Has something changed in the new security version or is this type of manual login is deprecated?
The text was updated successfully, but these errors were encountered: