doganoo / simple-rbac
Simple leightweight PHP Role Based Access Control library
Requires
- ext-json: *
- doganoo/php-algorithms: ^2.0
- laminas/laminas-diactoros: ^2.18
- laminas/laminas-servicemanager: ^3.16
- mezzio/mezzio: ^3.11
Requires (Dev)
- ergebnis/composer-normalize: ^2.28
- phpcompatibility/php-compatibility: ^9.3
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.7
README
Simple leightweight PHP Role Based Access Control library
How does this library work?
I have tried to keep things simple. The main idea was to let the user implement an interface which provides the user and his permissions. The permissions are assigned to roles and roles are assigned to users.
The library provides a simple way to verify permissions without re-inventing the wheel.
The library is also available on Packagist: https://packagist.org/packages/doganoo/simple-rbac
missing something? create a pull request!
Changelog
- 1.3.0 supporting owners:
Installation
You can install the package via composer:
composer require doganoo/simple-rbac
Usage
There are two main interfaces you have to implement:
* doganoo\SimpleRBAC\Common\IUser
* doganoo\SimpleRBAC\Common\IDataProvider
The first interface represents the user to whom permissions are granted or denied. The second interface holds all necessary information, such as the user, a single permission and default permissions.
IDataProvider can be used to connect to a data source (database, files, HTTP, etc.) in order to set up.
The doganoo\SimpleRBAC\Handler\PermissionHandler
class uses the interfaces above to determine whether an action is permitted or not.
doganoo\SimpleRBAC\Common\IPermission
and doganoo\SimpleRBAC\Common\IRole
interfaces represent a single permission and a user's role.
Contributions
Feel free to send a pull request to add more algorithms and data structures.
Maintainer/Creator
Doğan Uçar (@doganoo)
License
MIT