scento / merowinger
The PHP ACL library controlling the keymaker.
Requires
- php: >=7.0.0
- ext-json: *
Requires (Dev)
- cvuorinen/phpdoc-markdown-public: @stable
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: @stable
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2020-01-24 16:13:59 UTC
README
Merowinger is the ACL library for PHP controlling the keymaker in an easy and minimalistic way. This library provides the following features:
- Role Management
- Role Inheritance
- Resource and Action Management
- Allow and Deny rules per
- Role
- Resource
- Action
- ACL Serialization
Installation
One can install this library with composer
. This package only requires PHP >=7.0.0
and the json
extension to work properly. If you want to use Merowinger without composer
, you can configure your autoloader to include files in the Merowinger\
namespace from src/
of the project root directory.
Example
<?php use Merowinger\Access; use Merowinger\Acl; use Merowinger\Role; $acl = new Acl(); $acl->setDefaultAccess(Access::DENY); //Create Roles $applications = new Role('Application'); $humans = new Role('Human'); $rebels = new Role('Rebel'); $rebels->inherits($humans); $population = new Role('Population'); $population->inherits($humans); $merowinger = new Role('Merowinger'); $merowinger->inherits($applications); $agents = new Role('Agent'); $agents->inherits($applications); $agents->inherits($humans); $neo = new Role('Neo'); $neo->inherits($rebels); //Register Roles And Resources $acl->addResource('Matrix', ['liveIn', 'see', 'control', 'destroy']); $acl->addResource('Keymaker', ['know', 'control']); $acl->addRole($applications); $acl->addRole($humans); $acl->addRole($rebels); $acl->addRole($population); $acl->addRole($agents); $acl->addRole($neo); $acl->addRole($merowinger); //Grant permissions $acl->allow('Population', 'Matrix', 'liveIn'); $acl->allow('Application', 'Matrix', ['control', 'see']); $acl->allow('Rebel', 'Keymaker', 'know'); $acl->allow('Rebel', 'Matrix', ['liveIn', 'see']); $acl->allow('Neo', 'Matrix'); //Grant full access to resource matrix $acl->allow('Merowinger', 'Keymaker', ['know', 'control']); $acl->allow('Agent', 'Matrix', 'control'); //Check whether Neo can destroy the matrix $acl->isAllowed('Neo', 'Matrix', 'destroy'); //returns Access::ALLOW //Check whether the population can control the matrix $acl->isAllowed('Population', 'Matrix', 'control'); //returns Access::DENY
Development
All contributions to this project should be PSR-2 compliant. In addition to that, we are using PHPDoc annotations and write PHPUnit tests. The following command can be used to execute all test locally. Please do this before committing:
vendor/bin/phpunit --debug --verbose --configuration test/unit.xml
This repository follows the Semantic Versioning paradigm. All major changes are documented in the Changelog, following the Keep a Changelog principle.
License
This library is licensed under the terms of the MIT license.