问题描述
我注意到即使是SuperAdmin用户也要征求我的选民.
I noticed that my voters are solicited even for SuperAdmin users.
它按预期工作吗?
如果是的话,我认为SuperAdmin的理念是系统地拥有他们的所有权利,因此我们不必一个个地授予他们每个许可.在那种情况下,为什么不授予所有选民访问权限?
If yes, I thought that the philosophy of SuperAdmin is that they systematically have all rights, so that we don't have to give them each permission one by one. In that case why not granting access to all voters ?
我是否总是必须放
if ($user->isSuperAdmin()) {
return VoterInterface::ACCESS_GRANTED;
}
在我的选民中?
推荐答案
在IddqdVoter
类中,您具有一个特殊角色,称为ROLE_IDDQD
.
In the IddqdVoter
class, you have a special role called ROLE_IDDQD
.
此选民添加了特殊角色ROLE_IDDQD
,可有效绕过任何和所有安全检查(包括选民).
This voter adds a special role ROLE_IDDQD
which effectively bypasses any, and all security checks (including voters).
这就是您要寻找的.更多: IDDQD选民
This is what you're looking for. More : IDDQD Voter
您甚至可以为IDDQD角色设置别名,因此我想您可以将ROLE_SUPER_ADMIN
别名为ROLE_IDDQD
.如果您无法执行此操作,只需授予ROLE_SUPER_ADMIN
和ROLE_IDDQD
即可,然后就可以开始使用了.
You can even set an alias for the IDDQD role, so I guess that you can alias the ROLE_SUPER_ADMIN
to the ROLE_IDDQD
. If you can't do that, simply grant the ROLE_SUPER_ADMIN
the ROLE_IDDQD
and you're ready to go.
要使用此特殊角色,您必须通过以下方式启用它:
In order to use this special role, you'll have to enable it by doing so :
#config.yml
jms_security_extra:
enable_iddqd_attribute: true
这篇关于Symfony2-为什么甚至为超级管理员也召集选民的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!