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] deprecate the Role and SwitchUserRole classes#22048

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:masterfromxabbuh:deprecate-role-class
Feb 25, 2019

Conversation

@xabbuh
Copy link
Member

@xabbuhxabbuh commentedMar 17, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets#20824
LicenseMIT
Doc PRsymfony/symfony-docs#11047

In#20801, we deprecated theRoleInterface. The next logical step would be to also deprecate theRole class. However, we currently have theSwitchUserRole class (a sub-class ofRole) that acts as an indicator to check whether or not the authenticated user switched to another user.

This PR proposes an alternative solution to the usage of the specialSwitchUserRole class by storing the original token inside theUsernamePasswordToken. This PR is not complete, but rather acts as a proof of concept of how we could get rid of theRole and theSwitchUserRole classes.

Please share your opinions whether you think this is a valid approach and I will be happy to finalise the PR.

jvasseur, ro0NL, RSalo, Koc, and andreybolonin reacted with thumbs up emoji
@xabbuhxabbuhforce-pushed thedeprecate-role-class branch 2 times, most recently froma8df9f2 to1aec9b7CompareMarch 18, 2017 09:13
fabpot added a commit that referenced this pull requestMar 22, 2017
This PR was merged into the 2.7 branch.Discussion----------[Security] simplify the SwitchUserListenerTest| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |While working on#22048 I noticed that the `SwitchUserListenerTest` was more complicated than necessary by mocking a lot of stuff that didn't need to be mocked.Commits-------923bbdb [Security] simplify the SwitchUserListenerTest
@nicolas-grekasnicolas-grekas added this to the3.x milestoneMar 24, 2017
@xabbuhxabbuh changed the base branch frommaster to3.4May 18, 2017 07:16
@xabbuh
Copy link
MemberAuthor

@symfony/deciders I would like to hear your opinion on this topic? Do you think it's worth to finish this approach? Should we take another road?

@nicolas-grekas
Copy link
Member

@fabpot@stof you might be the best to help here?

@chalasr
Copy link
Member

IMO it's a good move. We still need to be able to get both impersonator/impersonated user from the token, I guess it's planed

@xabbuh
Copy link
MemberAuthor

IMO it's a good move. We still need to be able to get both impersonator/impersonated user from the token, I guess it's planed

@chalasr I guess theSwitchUserToken (or maybe betterSwitchedUserToken) suggested by@HeahDude could be a good solution.

Koc and HeahDude reacted with heart emoji

@chalasr
Copy link
Member

Agreed, that would remove the need forisUserSwitched.

@nicolas-grekas
Copy link
Member

@xabbuh will you have tome to finish this PR for 3.4?

@xabbuh
Copy link
MemberAuthor

Yes, I am working on it.

@nicolas-grekas
Copy link
Member

should we move to 4.1?

@xabbuh
Copy link
MemberAuthor

I think so.

@nicolas-grekasnicolas-grekas modified the milestones:3.4,4.1Oct 8, 2017
@xabbuhxabbuh changed the base branch from3.4 tomasterNovember 15, 2017 19:48
@xabbuhxabbuhforce-pushed thedeprecate-role-class branch 3 times, most recently fromb871a65 tob2cfbb3CompareFebruary 22, 2019 23:11
@xabbuh
Copy link
MemberAuthor

tests pass now

Status: Needs Review

Copy link
Member

@javiereguiluzjaviereguiluz left a comment

Choose a reason for hiding this comment

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

Nice!

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commitd7aaa61 intosymfony:masterFeb 25, 2019
fabpot added a commit that referenced this pull requestFeb 25, 2019
…es (xabbuh)This PR was merged into the 4.3-dev branch.Discussion----------[Security] deprecate the Role and SwitchUserRole classes| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets |#20824| License       | MIT| Doc PR        |symfony/symfony-docs#11047In#20801, we deprecated the `RoleInterface`. The next logical step would be to also deprecate the `Role` class. However, we currently have the `SwitchUserRole` class (a sub-class of `Role`) that acts as an indicator to check whether or not the authenticated user switched to another user.This PR proposes an alternative solution to the usage of the special `SwitchUserRole` class by storing the original token inside the `UsernamePasswordToken`. This PR is not complete, but rather acts as a proof of concept of how we could get rid of the `Role` and the `SwitchUserRole` classes.Please share your opinions whether you think this is a valid approach and I will be happy to finalise the PR.Commits-------d7aaa61 deprecate the Role and SwitchUserRole classes
@xabbuhxabbuh deleted the deprecate-role-class branchFebruary 25, 2019 16:17
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestFeb 26, 2019
This PR was merged into the master branch.Discussion----------document the deprecation of the role classesseesymfony/symfony#22048Commits-------0fbef77 document the deprecation of the role classes
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since Symfony 4.3, to be removed in 5.0.
Copy link
Member

Choose a reason for hiding this comment

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

Why deprecating this interface instead of asking to implement the new method in it ? Removing the interface would remove a supported extension point.

xabbuh reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I don't remember why I did that initially. I guess it was due to an earlier implementation.#30388 will revert this part.

symfony-splitter pushed a commit to symfony/workflow that referenced this pull requestMar 23, 2019
…buh)This PR was merged into the 4.3-dev branch.Discussion----------[Security] undeprecate the RoleHierarchyInterface| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |symfony/symfony#22048 (comment)| License       | MIT| Doc PR        |Instead of deprecating the interface it is sufficient to deprecate itsgetReachableRoles() method and add a new getReachableRoleNames() methodin Symfony 5.Commits-------2d3f2b7a74 undeprecate the RoleHierarchyInterface
fabpot added a commit that referenced this pull requestMar 23, 2019
…buh)This PR was merged into the 4.3-dev branch.Discussion----------[Security] undeprecate the RoleHierarchyInterface| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22048 (comment)| License       | MIT| Doc PR        |Instead of deprecating the interface it is sufficient to deprecate itsgetReachableRoles() method and add a new getReachableRoleNames() methodin Symfony 5.Commits-------2d3f2b7 undeprecate the RoleHierarchyInterface
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
* @param(Role|string)[] $roles An array of roles
* @param UserInterface $user The user!
* @param string $providerKey The provider (firewall) key
* @param string[] $roles An array of roles
Copy link
Contributor

@gmponosgmponosJun 13, 2019
edited
Loading

Choose a reason for hiding this comment

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

Although theRole object is deprecated the$roles argument can still acceptRoles object..

this change breaks my phpstan when I have something like this:

$newToken = new PostAuthenticationGuardToken($user, 'secured_area', $user->getRoles());

would it be acceptable to revert this docblock change?

Copy link
Contributor

Choose a reason for hiding this comment

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

We normally do not document the deprecated arguments anymore. Same as if we deprecate an argument and use func_get_arg for BC. Otherwise people could think the deprecated way is still the right way and write code accordingly. So IMO we should not change that. Either fix the deprecation or ignore the phpstan error.

nicolas-grekas and xabbuh reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

We normally do not document the deprecated arguments anymore.

I guess the same does not applyhere because it is a return argument?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be changed there as well.

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

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@chalasrchalasrchalasr approved these changes

+3 more reviewers

@TobionTobionTobion left review comments

@gmponosgmponosgmponos left review comments

@HeahDudeHeahDudeHeahDude left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

10 participants

@xabbuh@nicolas-grekas@chalasr@fabpot@javiereguiluz@stof@Tobion@gmponos@HeahDude@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp