Skip to content

[Security] deprecate the RoleInterface #20801

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

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Dec 6, 2016

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets
License MIT
Doc PR

* @param RoleInterface[]|string[] $roles An array of roles
* @param UserInterface $user The user!
* @param string $providerKey The provider (firewall) key
* @param Role[]|string[] $roles An array of roles
Copy link
Member

@yceruto yceruto Dec 6, 2016

Choose a reason for hiding this comment

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

same as before (Role|string)[] ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course, good catch @yceruto!

@xabbuh xabbuh force-pushed the deprecate-role-interface branch from 48507c6 to 807b60d Compare December 6, 2016 21:53
@ogizanagi
Copy link
Contributor

What about triggering a deprecation at least from the SecurityDataCollector in case a role does implement RoleInterface without extending Role?

@xabbuh
Copy link
Member Author

xabbuh commented Dec 6, 2016

@ogizanagi But such a role would have triggered the deprecation already because of the @deprecated annotation in the RoleInterface (at least in the dev environment).

@ogizanagi
Copy link
Contributor

Right. I forgot about this behavior.

@@ -18,6 +18,8 @@
* supported by at least one AccessDecisionManager.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated The RoleInterface is deprecated since version 3.3 and will be removed in 4.0. Use the Symfony\Component\Security\Core\Role\Role class instead.
Copy link
Member

Choose a reason for hiding this comment

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

Extend the ... instead of Use the ...?

@xabbuh xabbuh force-pushed the deprecate-role-interface branch from 807b60d to 0393724 Compare December 7, 2016 08:55
@nicolas-grekas nicolas-grekas modified the milestone: 3.x Dec 7, 2016
@fabpot
Copy link
Member

fabpot commented Dec 8, 2016

Thank you @xabbuh.

@fabpot fabpot merged commit 0393724 into symfony:master Dec 8, 2016
fabpot added a commit that referenced this pull request Dec 8, 2016
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Security] deprecate the RoleInterface

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

0393724 [Security] deprecate the RoleInterface
@xabbuh xabbuh deleted the deprecate-role-interface branch December 8, 2016 07:50
@stof
Copy link
Member

stof commented Dec 8, 2016

@fabpot we talked about deprecating the usage of objects as roles entirely in the past, relying on strings only. Should we move forward on this topic ?

@fabpot
Copy link
Member

fabpot commented Dec 8, 2016

@stof Indeed, that would be a fantastic move for 4.0.

@fsmeier
Copy link

fsmeier commented Apr 17, 2018

@fabpot we talked about deprecating the usage of objects as roles entirely in the past, relying on strings only. Should we move forward on this topic ?

Where was this discussed? Can you pls link this, so others and me can understand why this is the better way?

fabpot added a commit that referenced this pull request Feb 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#11047

In #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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants