Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teodoroleckie/acl
⚡ Tleckie\Acl component provides a lightweight and flexible access control list (ACL) implementation for privileges management.
https://github.com/teodoroleckie/acl
access-control-list acl permissions php php8 resource-permissions
Last synced: 3 days ago
JSON representation
⚡ Tleckie\Acl component provides a lightweight and flexible access control list (ACL) implementation for privileges management.
- Host: GitHub
- URL: https://github.com/teodoroleckie/acl
- Owner: teodoroleckie
- License: mit
- Created: 2021-04-30T13:42:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-13T08:51:07.000Z (over 3 years ago)
- Last Synced: 2024-05-02T04:13:10.982Z (5 months ago)
- Topics: access-control-list, acl, permissions, php, php8, resource-permissions
- Language: PHP
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Tleckie\Acl access control list (ACL)
Tleckie\Acl component provides a lightweight and flexible access control list (ACL) implementation for privileges management.
In general, an application may utilize such ACL‘s to control access to certain protected objects by other requesting objects.[![Latest Version on Packagist](https://img.shields.io/packagist/v/tleckie/acl.svg?style=flat-square)](https://packagist.org/packages/tleckie/acl)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teodoroleckie/acl/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/acl/?branch=main)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/teodoroleckie/acl/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence)
[![Build Status](https://scrutinizer-ci.com/g/teodoroleckie/acl/badges/build.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/acl/build-status/main)## Installation
You can install the package via composer:
```bash
composer require tleckie/acl
```## Usage
```php
addRole('USER-0');
$acl->addRole('USER-1', ['USER-0']); // (USER-0) parent role.
$acl->addRole('USER-2', ['USER-1']); // (USER-1) parent role.$acl->addResource('RESOURCE-0');
$acl->addResource('RESOURCE-1', ['RESOURCE-0']); // (RESOURCE-0) parent resource.
$acl->addResource('RESOURCE-2', ['RESOURCE-1']); // (RESOURCE-1) parent resource.
$acl->addResource('RESOURCE-3', ['RESOURCE-2']); // (RESOURCE-2) parent resource.$acl->allow(['USER-0'], ['RESOURCE-0']);
$acl->deny(['USER-1'], ['RESOURCE-3'],['view','edit','list']);$acl->isAllowed('USER-0','RESOURCE-2'); // true
$acl->isAllowed('USER-1','RESOURCE-3'); // true
$acl->isAllowed('USER-1','RESOURCE-3', 'view'); // false
$acl->isAllowed('USER-2','RESOURCE-3'); // true
$acl->isAllowed('USER-2','RESOURCE-3', 'view'); // false
```