Download the PHP package craftcamp/php-abac without Composer
On this page you can find all versions of the php package craftcamp/php-abac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download craftcamp/php-abac
More information about craftcamp/php-abac
Files in craftcamp/php-abac
Package php-abac
Short Description Library used to implement Attribute-Based Access Control in a PHP application
License MIT
Informations about the package php-abac
[CraftCamp] php-abac
Attribute-Based Access Control implementation library
Introduction
This library is meant to implement the concept of ABAC in your PHP applications.
The concept is to manage access control using attributes : from users, from resources and environment.
It allows us to define rules based on the properties of the user object and optionally the accessed object.
These rules will be checked in your application to determine if an user is allowed to perform an action.
The following links explain what ABAC is :
Installation
Using composer :
Then you will have to configure the attributes and the rules of your application.
For more details about this, please refer to the dedicated documentation
Documentation
- Configuration
- Dependency Injection
- Access-control
- Comparisons
- Caching
Usage Examples
Example with only user attributes defined in the rule
We have in this example a single object, representing the current user.
This object have properties, with getter methods to access the values.
For example, we can code :
The attributes checked by the rule can be :
User |
---|
isBanned = false |
Example with both user and object attributes
The checked attributes can be :
User | Group |
---|---|
isBanned = 0 | isActive = 1 |
isPublic = 1 |
Example with dynamic attributes
Example with referenced attributes
The configuration shall be :
And then the code :
Example with cache
Example with multiple rules (ruleSet) for an unique rule. Each rule are tested and the treatment stop when the first rule of the ruleSet allow access
The configuration shall be (alcoolaw.yml):
And then the code :
Example with rules root directory passed to Abac class. This feature allow to give a policy definition rules directory path directly to the Abac class without adding to all files :
Considering we have 3 yaml files :
- rest/conf/policy/user_def.yml
- rest/conf/policy/gunlaw.yml
The php code can be :
Contribute
If you want to contribute, don't hesitate to fork the library and submit Pull Requests.
You can also report issues, suggest enhancements, feel free to give advices and your feedback about this library.
It's not finished yet, there's still a lot of features to implement to make it better. If you want to be a part of this library improvement, let us know !
See also
All versions of php-abac with dependencies
psr/cache Version ~1.0
symfony/config Version ~3.0|^4.0
symfony/yaml Version ~3.0|^4.0
friendsofphp/php-cs-fixer Version ^2.12