Skip to content

Commit ebd539f

Browse files
committed
白名单鉴权
白名单鉴权
1 parent 8ff9e06 commit ebd539f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

application/api/controller/Api.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class Api
1919

2020
protected $clientInfo;
2121

22+
/**
23+
* 不需要鉴权方法
24+
*/
25+
protected $noAuth = [];
26+
2227
/**
2328
* 构造方法
2429
* @param Request $request Request对象

application/api/controller/v1/User.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
use app\api\controller\Api;
88

99
class User extends Api
10-
{
10+
{
11+
/**
12+
* 不需要鉴权方法
13+
* * 表示全部不需要授权
14+
* ['index','save']
15+
*/
16+
protected $noAuth = [];
17+
1118
/**
1219
* 显示资源列表
1320
*

config/app.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,4 @@
142142
'show_error_msg' => false,
143143
// 异常处理handle类 留空使用 \think\exception\Handle
144144
'exception_handle' => '\\app\\api\\exception\\ExceptionHandler',
145-
//某些方法不需要使用接口鉴权,一些公共类方法
146-
'allow_method'=>[
147-
'V1.User/index/get', //post方法允许直接访问
148-
]
149-
150145
];

0 commit comments

Comments
 (0)