zielony/conditionacl

简单的条件访问控制列表

v1.0.2 2021-07-30 15:05 UTC

This package is auto-updated.

Last update: 2024-09-29 06:03:03 UTC


README

Conditionacl 是一个简单的访问控制列表(ACL)系统实现,在验证规则时还考虑了外部条件。

使用示例

$aclFactory = new AclFactory(new YamlFileConfig('...'));
$acl = $aclFactory->fromRole('project-reader');

$user1 = new Domain\User(1, 'user1');
$user2 = new Domain\User(2, 'user2');

$project = new Domain\Project(1, 'first', $user1);

$acl->hasPermissionTo('read', 'project', new Condition\IfUserIsProjectsOwner($user1, $project));
// true

$acl->hasPermissionTo('read', 'project', new Condition\IfUserIsProjectsOwner($user2, $project));
// false