ahmed-ghiloubi / acl-bundle
提供了一种简单的方式来使用Symfony Security Acl。
4.0
2020-04-15 16:26 UTC
Requires
- php: >=7.2.0
- doctrine/common: ^2.12
- symfony/framework-bundle: ^4.0
- symfony/security: ^4.4
Requires (Dev)
- doctrine/doctrine-bundle: ^2.0
- doctrine/orm: ^2.7
- symfony/browser-kit: ^4.0
- symfony/expression-language: ^4.0
- symfony/finder: ^4.0
- symfony/security-bundle: ^4.0
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 not auto-updated.
Last update: 2024-09-19 21:01:12 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许可证。