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

#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

Merged
fabpot merged 1 commit intosymfony:4.4fromoleg-andreyev:issue-21571
Sep 6, 2019

Conversation

@oleg-andreyev
Copy link
Contributor

@oleg-andreyevoleg-andreyev commentedApr 18, 2019
edited
Loading

QA
Branch?4.4
Bug fix?yes
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT
Fixed tickets#21571 (comment)
Docssymfony/symfony-docs#11457

Case 1:
User A has rolesfoo, bar and admin, User A is signed-in into application and token is persisted, later another User B with roleadmin, decided to restrict roleadmin for User A, so User A won't lose it's privileges until session is expired or logout, because token is persisted withroles andauthenticated=true and roles are not compared.

Ref. to the previous attempt:#27121

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneApr 19, 2019
@fabpot
Copy link
Member

This looks like a new feature to me, I would target master.

OskarStark and oleg-andreyev reacted with thumbs up emoji

@oleg-andreyevoleg-andreyev changed the base branch from3.4 tomasterJune 11, 2019 12:00
@oleg-andreyev
Copy link
ContributorAuthor

This looks like a new feature to me, I would target master.

Changed to master

@OskarStark
Copy link
Contributor

Changed to master

Thank you, but now it should target4.4, asmaster is for Symfony 5 features now ;-)

@oleg-andreyev
Copy link
ContributorAuthor

Thank you, but now it should target4.4, asmaster is for Symfony 5 features now ;-)

It seems that documentation needs to be improvedhttps://symfony.com/doc/current/contributing/code/pull_requests.html#choose-the-right-branch

OskarStark reacted with thumbs up emoji

@oleg-andreyevoleg-andreyev changed the base branch frommaster to4.4June 11, 2019 14:43
@oleg-andreyev
Copy link
ContributorAuthor

oleg-andreyev commentedJun 13, 2019
edited
Loading

Thank you, but now it should target4.4, asmaster is for Symfony 5 features now ;-)

@OskarStark can you please explain how it should be (I'd like to prepare PR):

  • bug fixes go to corresponded branch
  • new feature go to master branch (5.x)

but why then this PR, should be pointed to 4.4?
also it seems that it contradicts with@fabpot comment

@OskarStark
Copy link
Contributor

OskarStark commentedJun 13, 2019
edited
Loading

https://symfony.com/doc/current/contributing/code/pull_requests.html#choose-the-right-branch

Currently we are in state where4.3 is stable,4.4 will be the next version with new features andmaster will be the new 5.0 major version. So4.4 should be the correct branch.

This looks like a new feature to me, I would target master.

Thecomment by@fabpot was made before the new4.4 branch was born, correct@fabpot ?

cc@javiereguiluz

@fabpot
Copy link
Member

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
Copy link
ContributorAuthor

Alright I've createdsymfony/symfony-docs#11741, so this PR can be finally reviewed.

javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull requestJun 14, 2019
…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
Copy link
Member

Tests for low are broken, which means that some constraints need to be changed (SecurityBundle depends on the Security component).

@oleg-andreyev
Copy link
ContributorAuthor

@fabpot the only way is to skipSecurityTest::testUserWillBeMarkedAsChangedIfRolesHasChanged for low, because it's a new test which was added in this PR.

Or there is another solution for such case?

@fabpot
Copy link
Member

fabpot commentedJun 19, 2019
edited
Loading

You can bump the minimum version for the dependency on SecurityBundle.

@oleg-andreyev
Copy link
ContributorAuthor

and it will pull changes from the current branch, right?

@xabbuh
Copy link
Member

@oleg-andreyev yes :)

@oleg-andreyev
Copy link
ContributorAuthor

@xabbuh thanks for explaining, didn't know that

@oleg-andreyev
Copy link
ContributorAuthor

Just some minor comments, but what I am more concerned about is that this will also log out users if they have been granted new roles. I suspect that this is something that is not expected.

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
Copy link
ContributorAuthor

Ready for review.

Travis failed with:

1) Symfony\Component\Mailer\Tests\TransportTest::testFromDsnMailgunstream_get_meta_data() expects parameter 1 to be resource, string given

@oleg-andreyev
Copy link
ContributorAuthor

@nicolas-grekas@fabpot@xabbuh@OskarStark please take a look.
Fail build is not related to changes in this PR.

@fabpot
Copy link
Member

@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
Copy link
ContributorAuthor

oleg-andreyev commentedSep 6, 2019
edited
Loading

@oleg-andreyev Can you squash your commits please?

Done.

@fabpot
Copy link
Member

Thank you@oleg-andreyev.

fabpot added a commit that referenced this pull requestSep 6, 2019
…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
@fabpotfabpot merged commit4f4c30d intosymfony:4.4Sep 6, 2019
@nicolas-grekasnicolas-grekas modified the milestones:next,4.4Oct 27, 2019
This was referencedNov 12, 2019
@XWB
Copy link
Contributor

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 removeUser::isEqualTo once we upgrade to Symfony 4.4? Will this feature have the same result?

@oleg-andreyev
Copy link
ContributorAuthor

@XWB yes, results will be the same.

@XWB
Copy link
Contributor

XWB commentedNov 19, 2019

@oleg-andreyev Thank you.

wouterj added a commit to wouterj/symfony that referenced this pull requestMay 29, 2020
nicolas-grekas added a commit that referenced this pull requestMay 30, 2020
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()
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark left review comments

@xabbuhxabbuhxabbuh left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

7 participants

@oleg-andreyev@fabpot@OskarStark@xabbuh@XWB@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp