11
11
12
12
An authorization library that supports access control models like ACL, RBAC, ABAC for webman plugin
13
13
14
- ## Installation
14
+ # 安装
15
15
16
16
``` sh
17
17
composer require -W casbin/webman-permission
18
18
```
19
19
20
- ## Configuration
20
+ # 使用
21
21
22
- ### 1. DI Configuration
22
+ > ** 1. 依赖注入配置 **
23
23
24
- ` config/container.php ` :
24
+ 修改配置 ` config/container.php ` ,其最终内容如下 :
25
25
26
26
``` php
27
27
$builder = new \DI\ContainerBuilder();
@@ -30,17 +30,19 @@ $builder->useAutowiring(true);
30
30
return $builder->build();
31
31
```
32
32
33
- ### 2. database
33
+ > ** 2. 数据库配置 **
34
34
35
- > 默认策略存储是使用的` ThinkORM ` 。
36
- > 如使用 ` laravel ` 的数据库 [ illuminate/database] ( https://github.com/illuminate/database ) ,请按照官方文档按照相应的依赖包:https://www.workerman.net/doc/webman/db/tutorial.html
35
+ 默认策略存储是使用的ThinkORM。
37
36
38
- ** 模型配置**
37
+ ** 1、 模型配置**
39
38
40
39
默认使用ThinkORM。修改数据库 ` thinkorm.php ` 配置
41
40
42
- ` casbin_rule ` 表
41
+ > 如使用laravel数据库,配置参考如下
42
+ - 修改数据库 ` database.php ` 配置
43
+ - 修改数据库 ` permission.php ` 的` adapter ` 适配器为laravel适配器
43
44
45
+ ** 2、创建 ` casbin_rule ` 数据表**
44
46
``` sql
45
47
CREATE TABLE `casbin_rule ` (
46
48
` id` BIGINT ( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -61,8 +63,9 @@ CREATE TABLE `casbin_rule` (
61
63
KEY ` idx_v5` ( ` v5` ) USING BTREE
62
64
) ENGINE = INNODB CHARSET = utf8mb4 COMMENT = ' 策略规则表' ;
63
65
```
66
+ ** 3、配置 ` config/redis ` 配置**
64
67
65
- ## 重启webman
68
+ ** 4、 重启webman**
66
69
67
70
```
68
71
php start.php restart
@@ -72,9 +75,7 @@ php start.php restart
72
75
php start.php restart -d
73
76
```
74
77
75
- ## 用法
76
-
77
- ### 快速开始
78
+ # 使用
78
79
79
80
安装成功后,可以这样使用:
80
81
@@ -99,7 +100,7 @@ if (\Casbin\WebmanPermission\Permission::enforce('eve', 'articles', 'edit')) {
99
100
}
100
101
```
101
102
102
- ### 多套驱动配置
103
+ # 多套驱动配置
103
104
104
105
``` php
105
106
$permission = \Casbin\WebmanPermission\Permission::driver('restful_conf');
@@ -119,14 +120,14 @@ if ($permission->enforce('eve', 'articles', 'edit')) {
119
120
120
121
更多 ` API ` 参考 [ Casbin API] ( https://casbin.org/docs/en/management-api ) 。
121
122
122
- ## 教程
123
+ # 教程
123
124
* [ Casbin权限实战:入门分享(中文)] ( https://www.bilibili.com/video/BV1A541187M4/?vd_source=a9321be9ed112f8d6fdc8ee87640be1b )
124
125
* [ Casbin权限实战:基于角色的RBAC授权] ( https://www.bilibili.com/video/BV1A541187M4/?vd_source=a9321be9ed112f8d6fdc8ee87640be1b )
125
126
* [ Casbin权限实战:RESTful及中间件使用] ( https://www.bilibili.com/video/BV1uk4y117up/?vd_source=a9321be9ed112f8d6fdc8ee87640be1b )
126
127
* [ Casbin权限实战:如何使用自定义匹配函数] ( https://www.bilibili.com/video/BV1dq4y1Z78g/?vd_source=a9321be9ed112f8d6fdc8ee87640be1b )
127
128
* [ Webman实战教程:如何使用casbin权限控制] ( https://www.bilibili.com/video/BV1X34y1Q7ZH/?vd_source=a9321be9ed112f8d6fdc8ee87640be1b )
128
129
129
- ## 感谢
130
+ # 感谢
130
131
131
132
[ Casbin] ( https://github.com/php-casbin/php-casbin ) ,你可以查看全部文档在其 [ 官网] ( https://casbin.org/ ) 上。
132
133
0 commit comments