Symfony2 ACL是否应用于检查SaaS中的所有权?

Symfony2 ACL是否应用于检查SaaS中的所有权?,symfony,acl,saas,multi-tenant,Symfony,Acl,Saas,Multi Tenant,在多租户web应用程序中,是否应使用Symfony2 ACL framework检查域对象的所有权 我无法得到这一点,因为(假设每个表都有一个对用户对象的反向引用),我可以简单地对照实体所有者id检查当前用户id,如下所示: /* * @Route("/edit/{slug}") * @Method("GET|POST") * @Secure(roles="ROLE_USER") * @Template */ public function editAction($slug); {

在多租户web应用程序中,是否应使用Symfony2 ACL framework检查域对象的所有权

我无法得到这一点,因为(假设每个表都有一个对
用户
对象的反向引用),我可以简单地对照实体所有者
id检查当前用户
id
,如下所示:

/*
 * @Route("/edit/{slug}")
 * @Method("GET|POST")
 * @Secure(roles="ROLE_USER")
 * @Template
 */
public function editAction($slug);
{
    // Find the post given the slug
    $repo    = $this->getDoctrine()->getRepository('AcmeHelloBundle:Post');
    $entity  = $repo->findOneBySlug($slug);
    $current = $this->get('security.contex')->getToken()->getUser();

    // 404 if slug is invalid
    if(!$entity) throw new $this->createNotFoundException();

    // AccessDenied if current user is not the owner of the entity
    if($current->getId() != $entity->getUser()->getId())
        throw new AccessDeniedException();
}

也许ACL可以帮助避免将每个实体反向引用到用户表?任何解释或示例都会很有帮助,谢谢。

ACL在多人可以访问同一域的情况下非常有用。有一个很好的例子


例如,假设您拥有为公司提供协作文档编辑的SaaS。公司可能希望限制对文档的访问,只允许公司的高管编辑文档,而不允许员工编辑文档。在这种情况下,您不能单独使用用户令牌,因为多个成员需要访问域。这就是ACL的用处所在。

您是如何着手解决这个问题的?我也面临同样的问题。我目前正在考虑通过修改Symfony中的AclProvider来创建CustomAclProvider,以便在我的所有选择和插入中添加租户id。