【问题标题】:How ACL is maintaned internally by Symfony2?Symfony2 如何在内部维护 ACL?
【发布时间】:2012-04-03 14:28:12
【问题描述】:

文档缺少有关ACL 的一些详细信息。就像在持久化域对象后在域对象上调用 createAcl 一样简单。然后在用户/对象上放置一个带有insertObjectAce 的掩码。

但是 Symfony2 内部如何管理 ACL?表格中是否添加了一些额外的列?

$entityManager = $this->get('doctrine.orm.default_entity_manager');
$entityManager->persist($comment);
$entityManager->flush();

// creating the ACL
$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($comment);
$acl = $aclProvider->createAcl($objectIdentity);

// retrieving the security identity of the currently logged-in user
$securityContext = $this->get('security.context');
$user = $securityContext->getToken()->getUser();
$securityIdentity = UserSecurityIdentity::fromAccount($user);

// grant owner access
$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);

【问题讨论】:

    标签: security doctrine symfony doctrine-orm acl


    【解决方案1】:

    它会创建一堆新表,

    在典型情况下,表格按从最少行到最多行的顺序排列 应用:

    • acl_security_identities:该表记录了所有持有 ACE 的安全身份 (SID)。默认实现附带两个
      安全身份:RoleSecurityIdentity 和 UserSecurityIdentity
    • acl_classes:此表将类名映射到一个唯一的 ID,该 ID 可以从其他表中引用。
    • acl_object_identities:此表中的每一行代表一个域对象实例。
    • acl_object_identity_ancestors:此表允许我们以非常有效的方式确定 ACL 的所有祖先。
    • acl_entries:此表包含所有 ACE。这通常是具有最多行的表。它可以包含数千万个,而不会显着影响性能。

    事实上,本章向你解释了很多关于 Symfony2 如何在内部管理 ACL 的内容:

    http://symfony.com/doc/current/cookbook/security/acl_advanced.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2016-10-11
      相关资源
      最近更新 更多