-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Docs unclear on roles property of access_control #6555
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
BTW I would be happy to update the documentation if necessary |
Strategies don't apply to roles, they are only used to aggregate votes from voters. This issue should be addressed to documentation repository https://github.com/symfony/symfony-docs |
I am fairly certain |
@scoolen it triggers the AccesDecisionManager because it is the one doing the decision. but the strategy used by the manager has nothing to do here. The strategy decides how the decisions of the different voters are taken into account to do the final decision. It has no impact on the way the RoleVoter does its own decision (the RoleVoter always does an OR when giving several role names) |
But that's what my issue is about. If you require two roles, which I accidentally interpreted as "either one of those roles" it appears to work (because of the looser strategy) in the default affirmative strategy, but doesn't work in unanimous mode. I guess alexandresalome is right and my (somewhat semantic) problem is a docs issue and belongs there. But still my question remains:
Thanks for the swift response btw |
Use JMSSecurityExtraBundle which provides a very powerful expression-based voter: http://jmsyst.com/bundles/JMSSecurityExtraBundle/master/expressions |
ping @fabpot this is good to close 👶 |
As of Symfony 2.4, expressions are built-in: http://symfony.com/blog/new-in-symfony-2-4-the-expressionlanguage-component#access-control-rules |
Suppose I have the following hierarchy of roles and access control definition:
I interpret this as: "Access is granted if user has one of the roles FOO or BAR"
And that is the way it (appears) to work with the default Affermative strategy.
However with Unanimous strategy I believe it works counter-intuitive: "Access is granted if user has all of the roles FOO and BAR"
I guess I missed the s in the documentation:
Also
Apart from declaring just
ROLE_USER
how would it be possible in the latter situation to grant two different roles access to the same resource?Then, if you look at security.yml in symfony-standard it has two example entries under access_control:
This suggests _roles_ is more than just roles. The AuthenticatedVoter (in this example) and any custom voters are also called with the attributes of the roles property.
The text was updated successfully, but these errors were encountered: