msi / acl-bundle
提供了一种简单的方式来使用Symfony安全Acl。
v1.1.0
2015-09-10 21:28 UTC
Requires
- php: >=5.3.0
- doctrine/common: ~2.2
- symfony/framework-bundle: ~2.3
- symfony/security: ~2.3
Requires (Dev)
- doctrine/doctrine-bundle: ~1.0
- doctrine/orm: ~2.2
- symfony/browser-kit: ~2.3
- symfony/expression-language: ~2.4
- symfony/finder: ~2.3
- symfony/security-bundle: ~2.3
Suggests
- doctrine/mongodb-odm: Allows you to remove Acl entries automatically. (When using MongoDB for Acl)
- doctrine/orm: Allows you to remove Acl entries automatically. (When using ORM for Acl)
This package is auto-updated.
Last update: 2024-08-29 04:46:17 UTC
README
为Symfony2提供对复杂的ACL子系统的简单访问的Bundle
描述
这个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许可证。