msi/acl-bundle

提供了一种简单的方式来使用Symfony安全Acl。

维护者

详细信息

github.com/massil31/AclBundle

源代码

安装: 426

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 4

类型:symfony-bundle

v1.1.0 2015-09-10 21:28 UTC

This package is auto-updated.

Last update: 2024-08-29 04:46:17 UTC


README

为Symfony2提供对复杂的ACL子系统的简单访问的Bundle

Latest Stable Version Total Downloads License Build Status Coverage Status SensioLabsInsight

描述

这个Symfony 2 Bundle提供了一个简单的API来访问Security/ACL组件,并在删除域对象时自动清理ACL的事件监听器。安装简单,默认情况下不会更改您的应用程序的任何行为。

没有这个bundle,您通常会这样做(摘自ACL文档

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

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

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

有了这个bundle,您可以简化为

$tokenStorage = $container->get('security.token_storage');
$user = $tokenStorage->getToken()->getUser();

$aclManager = $container->get('projecta_acl.manager');
$aclManager->manageObjectAces()
    ->grant($domainObject, MaskBuilder::MASK_OWNER, $user);

文档

最新文档可以在aclbundle.chililabs.org找到。

测试

要运行测试套件,您需要composer

$ composer install
$ phpunit

许可证

ChiliLabs AclBundle采用MIT许可证。