mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-08-30 04:39:46 +08:00
modified 完成接口鉴权
This commit is contained in:
parent
55a34757b3
commit
db76f641f5
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace app\http\middleware;
|
namespace app\http\middleware;
|
||||||
|
|
||||||
|
use app\util\ReturnCode;
|
||||||
|
|
||||||
class ApiPermission {
|
class ApiPermission {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,9 +14,19 @@ class ApiPermission {
|
|||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function handle($request, \Closure $next) {
|
public function handle($request, \Closure $next) {
|
||||||
|
$header = config('apiadmin.CROSS_DOMAIN');
|
||||||
$appInfo = $request->APP_CONF_DETAIL;
|
$appInfo = $request->APP_CONF_DETAIL;
|
||||||
$apiInfo = $request->API_CONF_DETAIL;
|
$apiInfo = $request->API_CONF_DETAIL;
|
||||||
|
|
||||||
|
$allRules = explode(',', $appInfo['app_api']);
|
||||||
|
if (!in_array($apiInfo['hash'], $allRules)) {
|
||||||
|
return json([
|
||||||
|
'code' => ReturnCode::INVALID,
|
||||||
|
'msg' => '非常抱歉,您没有权限这么做!',
|
||||||
|
'data' => []
|
||||||
|
])->header($header);
|
||||||
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user