zielony/conditionacl

Simple access-control list with conditions

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

This package is auto-updated.

Last update: 2024-04-29 05:05:26 UTC


README

Conditionacl is an implementation of a simple access-control list (ACL) system that also takes external conditions into account when validating the rules.

Example usage:

$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