innmind / acl
Reproduce the filesystem ACL mechanism
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
pkg:composer/innmind/acl
Requires
- php: ~8.2
- innmind/immutable: ~4.0|~5.0
Requires (Dev)
- innmind/black-box: ~5.5
- innmind/coding-standard: ~2.0
- nikic/php-parser: ^4.13.2
- phpunit/phpunit: ~10.2
- vimeo/psalm: ~5.12
This package is auto-updated.
Last update: 2025-09-19 16:34:33 UTC
README
Small library to reproduce the logic of the unix filesystem access control list.
Installation
composer require innmind/acl
Usage
use Innmind\ACL\{ ACL, User, Group, Mode, }; $acl = ACL::of('r---w---x user:group'); $acl->allows(User::of('foo'), Group::of('bar'), Mode::read); // false $acl->allows(User::of('foo'), Group::of('bar'), Mode::write); // false $acl->allows(User::of('foo'), Group::of('bar'), Mode::execute); // true $acl->allows(User::of('foo'), Group::of('group'), Mode::read); // false $acl->allows(User::of('foo'), Group::of('group'), Mode::write); // true $acl->allows(User::of('foo'), Group::of('group'), Mode::execute); // true $acl->allows(User::of('user'), Group::of('bar'), Mode::read); // true $acl->allows(User::of('user'), Group::of('bar'), Mode::write); // false $acl->allows(User::of('user'), Group::of('bar'), Mode::execute); // true $acl->allows(User::of('user'), Group::of('group'), Mode::read); // true $acl->allows(User::of('user'), Group::of('group'), Mode::write); // true $acl->allows(User::of('user'), Group::of('group'), Mode::execute); // true $acl->toString(); // outputs "r---w---x user:group" $otherAcl = $acl->addUser(Mode::write); $acl->toString(); // outputs "r---w---x user:group" $otherAcl->toString(); // outputs "rw--w---x user:group"
The goal is to reproduce the logic of the filesystem ACL but at the application level so it can be persisted in a user entity and being completely decoupled from the real filesystem.