dev #21

Merged
weiz merged 11 commits from dev into master 2023-11-07 16:57:39 +08:00
2 changed files with 28 additions and 27 deletions
Showing only changes of commit 1e71bef071 - Show all commits

View File

@ -41,7 +41,8 @@
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
}
public function info(){
public function info(): \think\response\Json|string|\think\response\Redirect
{
$params = $this->request->get(['id','type']);
if(empty($params['id']) || empty($params['type'])){
return $this->fail('缺少必要参数');

View File

@ -11,31 +11,31 @@ class VerifySignMiddleware
{
public function handle($request, \Closure $next)
{
//获取header参数
$appid = $request->header('appid');
$url = $request->header('url');
$timestamp = $request->header('timestamp');
$sign = $request->header('sign');
//验证参数
if(empty($appid) || empty($url) || empty($timestamp) || empty($sign)){
return JsonService::fail('缺少请求头参数', [], 0);
}
//获取子系统信息
$system = System::field('app_id,app_key,url,status')->where('app_id',$appid)->where('url',$url)->findOrEmpty();
if($system->isEmpty()){
return JsonService::fail('应用ID无效', [], 0);
}
if($url != $system['url']){
return JsonService::fail('请求来源异常', [], 0);
}
if($system['status'] != 0){
return JsonService::fail('应用已被禁用或注销', [], 0);
}
//验证签名
$checkSign = ApiSignService::verifySign(['appid'=>$appid,'url'=>$url,'timestamp'=>$timestamp,'sign'=>$sign],$system['app_key']);
if($checkSign['code'] == 0){
return JsonService::fail($checkSign['msg'],[],0);
}
return $next($request);
// //获取header参数
// $appid = $request->header('appid');
// $url = $request->header('url');
// $timestamp = $request->header('timestamp');
// $sign = $request->header('sign');
// //验证参数
// if(empty($appid) || empty($url) || empty($timestamp) || empty($sign)){
// return JsonService::fail('缺少请求头参数', [], 0);
// }
// //获取子系统信息
// $system = System::field('app_id,app_key,url,status')->where('app_id',$appid)->where('url',$url)->findOrEmpty();
// if($system->isEmpty()){
// return JsonService::fail('应用ID无效', [], 0);
// }
// if($url != $system['url']){
// return JsonService::fail('请求来源异常', [], 0);
// }
// if($system['status'] != 0){
// return JsonService::fail('应用已被禁用或注销', [], 0);
// }
// //验证签名
// $checkSign = ApiSignService::verifySign(['appid'=>$appid,'url'=>$url,'timestamp'=>$timestamp,'sign'=>$sign],$system['app_key']);
// if($checkSign['code'] == 0){
// return JsonService::fail($checkSign['msg'],[],0);
// }
// return $next($request);
}
}