Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
#21571 Comparing roles to detected that users has changed#31177
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedMay 15, 2019
This looks like a new feature to me, I would target master. |
src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
oleg-andreyev commentedJun 11, 2019
Changed to master |
OskarStark commentedJun 11, 2019
Thank you, but now it should target |
oleg-andreyev commentedJun 11, 2019
It seems that documentation needs to be improvedhttps://symfony.com/doc/current/contributing/code/pull_requests.html#choose-the-right-branch |
oleg-andreyev commentedJun 13, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@OskarStark can you please explain how it should be (I'd like to prepare PR):
but why then this PR, should be pointed to 4.4? |
OskarStark commentedJun 13, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Currently we are in state where
Thecomment by@fabpot was made before the new |
fabpot commentedJun 13, 2019
New features should indeed target the 4.4 branch. It's not the master branch as we have 2 new versions at the same time: 4.4 and 5.0 (which is special as it happens only once every two years). |
oleg-andreyev commentedJun 13, 2019
Alright I've createdsymfony/symfony-docs#11741, so this PR can be finally reviewed. |
src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AbstractTokenCompareRoles/bundles.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…ment branch instead of master for new features. (oleg-andreyev)This PR was merged into the 3.4 branch.Discussion----------Adding "special case" when need to select development branch instead of master for new features.As per discussion insymfony#11457 andsymfony/symfony#31177 (comment) updated section on how to select branchCommits-------1c2bae2 added "special case"
fabpot commentedJun 19, 2019
Tests for low are broken, which means that some constraints need to be changed (SecurityBundle depends on the Security component). |
oleg-andreyev commentedJun 19, 2019
@fabpot the only way is to skip Or there is another solution for such case? |
fabpot commentedJun 19, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
You can bump the minimum version for the dependency on SecurityBundle. |
oleg-andreyev commentedJun 19, 2019
and it will pull changes from the current branch, right? |
xabbuh commentedJun 19, 2019
@oleg-andreyev yes :) |
oleg-andreyev commentedJun 20, 2019
@xabbuh thanks for explaining, didn't know that |
oleg-andreyev commentedJul 14, 2019
I can understand this concern but theoretically we can add new role which actually limits previous roles and because we can't detect it the easiest way to ensure that ROLE will be taken into account is to logout user and force them to login again. |
oleg-andreyev commentedJul 23, 2019
Ready for review. Travis failed with: |
Uh oh!
There was an error while loading.Please reload this page.
oleg-andreyev commentedSep 6, 2019
@nicolas-grekas@fabpot@xabbuh@OskarStark please take a look. |
fabpot commentedSep 6, 2019
@oleg-andreyev Can you squash your commits please? |
- Updated isEqualTo method to match roles as default User implements EquatableInterface- added test case- bumped symfony/security-core to 4.4
oleg-andreyev commentedSep 6, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Done. |
fabpot commentedSep 6, 2019
Thank you@oleg-andreyev. |
…ged (oleg-andreyev)This PR was merged into the 4.4 branch.Discussion----------#21571 Comparing roles to detected that users has changed| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| License | MIT| Fixed tickets |#21571 (comment)| Docs |symfony/symfony-docs#11457**Case 1:**User A has roles `foo, bar and admin`, User A is signed-in into application and token is persisted, later another User B with role `admin`, decided to restrict role `admin` for User A, so User A won't lose it's privileges until session is expired or logout, because token is persisted with `roles` and `authenticated=true` and roles are not compared.Ref. to the previous attempt:#27121Commits-------4f4c30d - updated AbstractToken to compare Roles - Updated isEqualTo method to match roles as default User implements EquatableInterface - added test case - bumped symfony/security-core to 4.4
XWB commentedNov 17, 2019
@oleg-andreyev We are doing something similar in our User entity: namespaceApp\Entity;useSymfony\Component\Security\Core\User\EquatableInterface;class Userimplements EquatableInterface{publicfunctionisEqualTo(UserInterface$user) {$isEqual =count($this->getRoles()) ===count($user->getRoles());if ($isEqual) {foreach ($this->getRoles()as$role) {$isEqual =$isEqual &&in_array($role,$user->getRoles()); } }return$isEqual; }} Does that mean we can remove |
oleg-andreyev commentedNov 19, 2019
@XWB yes, results will be the same. |
XWB commentedNov 19, 2019
@oleg-andreyev Thank you. |
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()
Uh oh!
There was an error while loading.Please reload this page.
Case 1:
User A has roles
foo, bar and admin, User A is signed-in into application and token is persisted, later another User B with roleadmin, decided to restrict roleadminfor User A, so User A won't lose it's privileges until session is expired or logout, because token is persisted withrolesandauthenticated=trueand roles are not compared.Ref. to the previous attempt:#27121