3
3
</h1 >
4
4
5
5
<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>
7
7
</p >
8
8
9
9
<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>
16
16
<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>
19
19
<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>
22
22
<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>
25
25
</p >
26
26
27
27
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.
35
35
* [ Using a middleware] ( #using-a-middleware )
36
36
* [ basic Enforcer Middleware] ( #basic-enforcer-middleware )
37
37
* [ HTTP Request Middleware ( RESTful is also supported )] ( #http-request-middleware--restful-is-also-supported- )
38
+ * [ Multiple enforcers] ( #multiple-enforcers )
38
39
* [ Using artisan commands] ( #using-artisan-commands )
39
40
* [ Cache] ( #using-cache )
40
41
* [ Thinks] ( #thinks )
@@ -274,6 +275,44 @@ Route::group(['middleware' => ['http_request']], function () {
274
275
});
275
276
```
276
277
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
+
277
316
### Using artisan commands
278
317
279
318
You can create a policy from a console with artisan commands.
0 commit comments