PHPackages                             craftcamp/php-abac - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. craftcamp/php-abac

ActiveLibrary[Security](/categories/security)

craftcamp/php-abac
==================

Library used to implement Attribute-Based Access Control in a PHP application

3.0.0(7y ago)987.1k31[5 issues](https://github.com/CraftCamp/php-abac/issues)[5 PRs](https://github.com/CraftCamp/php-abac/pulls)2MITPHPPHP &gt;=7.0CI failing

Since Aug 5Pushed 6y ago15 watchersCompare

[ Source](https://github.com/CraftCamp/php-abac)[ Packagist](https://packagist.org/packages/craftcamp/php-abac)[ RSS](/packages/craftcamp-php-abac/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (5)Versions (15)Used By (2)

\[CraftCamp\] php-abac
======================

[](#craftcamp-php-abac)

### Attribute-Based Access Control implementation library

[](#attribute-based-access-control-implementation-library)

[![Latest Stable Version](https://camo.githubusercontent.com/118c72a2ca9ede2e0f24b28323b8fe5e8b781062e13f6b4a327d1009c9ca6b14/68747470733a2f2f706f7365722e707567782e6f72672f637261667463616d702f7068702d616261632f762f737461626c65)](https://packagist.org/packages/craftcamp/php-abac)[![Latest Unstable Version](https://camo.githubusercontent.com/e8490a073fdbf2495a9bb494288f5c5f6b8d9b4ce7b8ac7a152fe7c55000478b/68747470733a2f2f706f7365722e707567782e6f72672f637261667463616d702f7068702d616261632f762f756e737461626c65)](https://packagist.org/packages/craftcamp/php-abac)[![Build Status](https://camo.githubusercontent.com/0eeaf525b2e36abaac78e7a58a86c27e4540797f9bda1c497890f1a8214f5a5d/68747470733a2f2f7472617669732d63692e6f72672f437261667443616d702f7068702d616261632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/CraftCamp/php-abac)[![Code Coverage](https://camo.githubusercontent.com/7245e11d9353e8b01ce1c26945c2e5eac0d141d1e48e229b8b53971a01a7f03a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f437261667443616d702f7068702d616261632f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/CraftCamp/php-abac/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f979d830dd39cd79233f5304054d59da7e225b47aa8dc1660106f55d82de0524/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f437261667443616d702f7068702d616261632f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/CraftCamp/php-abac/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/00fc3dcdc670096d6551a3a0b6856ff43c81a6997dd97751731f194e8af25b60/68747470733a2f2f706f7365722e707567782e6f72672f637261667463616d702f7068702d616261632f646f776e6c6f616473)](https://packagist.org/packages/craftcamp/php-abac)[![License](https://camo.githubusercontent.com/269e934d33a980395f4d408bb4673bdb9f9d86878181029ad3cd36241b974009/68747470733a2f2f706f7365722e707567782e6f72672f637261667463616d702f7068702d616261632f6c6963656e7365)](https://packagist.org/packages/craftcamp/php-abac)

Introduction
------------

[](#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 :

- [ABAC Introduction](http://www.axiomatics.com/attribute-based-access-control.html)
- [NIST specification](http://nvlpubs.nist.gov/nistpubs/specialpublications/NIST.sp.800-162.pdf)

Installation
------------

[](#installation)

**Using composer :**

```
composer require craftcamp/php-abac
```

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](doc/configuration.md)

Documentation
-------------

[](#documentation)

- [Configuration](doc/configuration.md)
- [Dependency Injection](doc/dependency-injection.md)
- [Access-control](doc/access-control.md)
- [Comparisons](doc/comparisons.md)
- [Caching](doc/caching.md)

Usage Examples
--------------

[](#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 :

```
