SonataUser - 具有角色安全性的自定义选民

时间:2013-07-08 15:08:04

标签: security symfony symfony-security

我正在将SonataAdmin与sonata.admin.security.handler.role一起使用(所以我这里不使用ACL)。

我正在尝试使用自定义选民限制对对象的访问。

服务

security.access.company_voter:
    class:      Application\...\Voter\CompanyVoter
    public:     false
    tags:
       - { name: security.voter }

选民 申请... \ Voter \ CompanyVoter.php

#...
public function vote(TokenInterface $token, $object, array $attributes) 
{
    get_class($object);
}
#...

但我总是得到Application\...\Voter\CompanyVoter的实例,而不是要限制的预期对象。

可能是什么原因?

你是否告诉我在使用角色安全处理程序时Sonata没有将对象传递给isGranted()

1 个答案:

答案 0 :(得分:1)

经过几个小时的搜索,我注意到收到的对象始终是NULLget_class(NULL)返回当前的类。)

经过几天的追求,事实证明,与ACL处理程序相反,角色处理程序the default implementation doesn't pass当前对象为isGranted()

然后我要扩展它。

my github issue中查看精彩的独白,了解更多详情。

相关问题