Skip to content

Commit 4246971

Browse files
committed
Add multiple enforcers docs.
1 parent 6e69d2b commit 4246971

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

README.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
</h1>
44

55
<p align="center">
6-
<strong>Laravel-authz is an authorization library for the laravel framework.</strong>
6+
<strong>Laravel-authz is an authorization library for the laravel framework.</strong>
77
</p>
88

99
<p align="center">
10-
<a href="https://travis-ci.org/php-casbin/laravel-authz">
11-
<img src="https://travis-ci.org/php-casbin/laravel-authz.svg?branch=master" alt="Build Status">
12-
</a>
13-
<a href="https://coveralls.io/github/php-casbin/laravel-authz">
14-
<img src="https://coveralls.io/repos/github/php-casbin/laravel-authz/badge.svg" alt="Coverage Status">
15-
</a>
10+
<a href="https://travis-ci.org/php-casbin/laravel-authz">
11+
<img src="https://travis-ci.org/php-casbin/laravel-authz.svg?branch=master" alt="Build Status">
12+
</a>
13+
<a href="https://coveralls.io/github/php-casbin/laravel-authz">
14+
<img src="https://coveralls.io/repos/github/php-casbin/laravel-authz/badge.svg" alt="Coverage Status">
15+
</a>
1616
<a href="https://packagist.org/packages/casbin/laravel-authz">
17-
<img src="https://poser.pugx.org/casbin/laravel-authz/v/stable" alt="Latest Stable Version">
18-
</a>
17+
<img src="https://poser.pugx.org/casbin/laravel-authz/v/stable" alt="Latest Stable Version">
18+
</a>
1919
<a href="https://packagist.org/packages/casbin/laravel-authz">
20-
<img src="https://poser.pugx.org/casbin/laravel-authz/downloads" alt="Total Downloads">
21-
</a>
20+
<img src="https://poser.pugx.org/casbin/laravel-authz/downloads" alt="Total Downloads">
21+
</a>
2222
<a href="https://packagist.org/packages/casbin/laravel-authz">
23-
<img src="https://poser.pugx.org/casbin/laravel-authz/license" alt="License">
24-
</a>
23+
<img src="https://poser.pugx.org/casbin/laravel-authz/license" alt="License">
24+
</a>
2525
</p>
2626

2727
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.
3535
* [Using a middleware](#using-a-middleware)
3636
* [basic Enforcer Middleware](#basic-enforcer-middleware)
3737
* [HTTP Request Middleware ( RESTful is also supported )](#http-request-middleware--restful-is-also-supported-)
38+
* [Multiple enforcers](#multiple-enforcers)
3839
* [Using artisan commands](#using-artisan-commands)
3940
* [Cache](#using-cache)
4041
* [Thinks](#thinks)
@@ -274,6 +275,44 @@ Route::group(['middleware' => ['http_request']], function () {
274275
});
275276
```
276277

278+
### Multiple enforcers
279+
280+
If you need multiple permission controls in your project, you can configure multiple enforcers.
281+
282+
In the lauthz file, it should be like this:
283+
284+
```php
285+
return [
286+
'default' => 'basic',
287+
288+
'basic' => [
289+
'model' => [
290+
// ...
291+
],
292+
293+
'adapter' => Lauthz\Adapters\DatabaseAdapter::class,
294+
// ...
295+
],
296+
297+
'second' => [
298+
'model' => [
299+
// ...
300+
],
301+
302+
'adapter' => Lauthz\Adapters\DatabaseAdapter::class,
303+
// ...
304+
],
305+
];
306+
307+
```
308+
309+
Then you can choose which enforcers to use.
310+
311+
```php
312+
Enforcer::guard('second')->enforce("eve", "articles", "edit");
313+
```
314+
315+
277316
### Using artisan commands
278317

279318
You can create a policy from a console with artisan commands.

0 commit comments

Comments
 (0)