modified 完成接口鉴权

This commit is contained in:
zhaoxiang 2019-07-01 00:06:50 +08:00
parent 55a34757b3
commit db76f641f5

View File

@ -2,6 +2,8 @@
namespace app\http\middleware;
use app\util\ReturnCode;
class ApiPermission {
/**
@ -12,9 +14,19 @@ class ApiPermission {
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
public function handle($request, \Closure $next) {
$header = config('apiadmin.CROSS_DOMAIN');
$appInfo = $request->APP_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);
}
}