diff --git a/README.md b/README.md index a191138..536b735 100755 --- a/README.md +++ b/README.md @@ -3,25 +3,25 @@

- Laravel-authz is an authorization library for the laravel framework. + Laravel-authz is an authorization library for the laravel framework.

- - Build Status - - - Coverage Status - + + Build Status + + + Coverage Status + - Latest Stable Version - + Latest Stable Version + - Total Downloads - + Total Downloads + - License - + License +

It's based on [Casbin](https://github.com/php-casbin/php-casbin), an authorization library that supports access control models like ACL, RBAC, ABAC. @@ -35,6 +35,7 @@ All you need to learn to use `Casbin` first. * [Using a middleware](#using-a-middleware) * [basic Enforcer Middleware](#basic-enforcer-middleware) * [HTTP Request Middleware ( RESTful is also supported )](#http-request-middleware--restful-is-also-supported-) + * [Multiple enforcers](#multiple-enforcers) * [Using artisan commands](#using-artisan-commands) * [Cache](#using-cache) * [Thinks](#thinks) @@ -274,6 +275,44 @@ Route::group(['middleware' => ['http_request']], function () { }); ``` +### Multiple enforcers + +If you need multiple permission controls in your project, you can configure multiple enforcers. + +In the lauthz file, it should be like this: + +```php +return [ + 'default' => 'basic', + + 'basic' => [ + 'model' => [ + // ... + ], + + 'adapter' => Lauthz\Adapters\DatabaseAdapter::class, + // ... + ], + + 'second' => [ + 'model' => [ + // ... + ], + + 'adapter' => Lauthz\Adapters\DatabaseAdapter::class, + // ... + ], +]; + +``` + +Then you can choose which enforcers to use. + +```php +Enforcer::guard('second')->enforce("eve", "articles", "edit"); +``` + + ### Using artisan commands You can create a policy from a console with artisan commands.