Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crisu83/overseer
Framework agnostic RBAC implementation in PHP
https://github.com/crisu83/overseer
Last synced: 23 days ago
JSON representation
Framework agnostic RBAC implementation in PHP
- Host: GitHub
- URL: https://github.com/crisu83/overseer
- Owner: crisu83
- License: mit
- Created: 2015-06-11T14:15:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-24T23:38:03.000Z (over 6 years ago)
- Last Synced: 2024-12-31T20:42:57.302Z (about 1 month ago)
- Language: PHP
- Size: 57.6 KB
- Stars: 18
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Overseer
Overseer is a framework agnostic [RBAC](http://en.wikipedia.org/wiki/Role-based_access_control) implementation in PHP.
## How does Overseer differ from other implementations?
Overseer is developed using PHP OOP best practices and meets the [PHP-FIG](http://www.php-fig.org/) standards. It is not only framework agnostic, but also storage agnostic, which allows you to use it together with your favorite libraries.
## Features
- Role inhertiance
- Permission business rules
- Resource based permissions
- Configurable## Work in progress
- Unit tests
- Refactoring
- README## Usage
Overseer comes bundled with a runtime storage implementation that is suitable for non-production use. If you plan on using Overseer in production we suggest that you implement persistent storage and caching to improve performance.
## Example
The following script demonstrates usage (you can find the rest of the code in the [example](example) folder):
```php
addRule(new AuthorRule);$writer->addPermission('book.write');
$writer->addPermission('book.author');
$editor->addPermission('book.read');$overseer->saveRole($writer);
$overseer->saveRole($editor);$overseer->savePermission($read);
$overseer->savePermission($write);
$overseer->savePermission($author);$overseer->saveAssignment(new Assignment(1, ['writer', 'editor']));
echo "My permissions: " . PHP_EOL;
echo " " . implode(', ', $overseer->getPermissions($myUser)) . PHP_EOL;echo "My permissions to the book: " . PHP_EOL;
echo " " . implode(', ', $overseer->getPermissions($myUser, $myBook)) . PHP_EOL;if ($overseer->hasPermission('book.author', $myUser, $myBook)) {
echo "I am the author of the book." . PHP_EOL;
} else {
echo "I am not the author of the book" . PHP_EOL;
}```
Here is the output from that script:
```
My permissions:
book.read, book.write
My permissions to the book:
book.read, book.write, book.author
I am the author of the book.
```