Commit cad80472 authored by hangjun83's avatar hangjun83

优化

parent 4fd03232
......@@ -80,7 +80,7 @@ class Authenticate
throw new UnauthorizedHttpException('JWTAuth','无效的平台token');
}
//验证平台来源
$result = $thirdPlatformService->checkUrlFrom($request->root());
$result = $thirdPlatformService->checkUrlFrom($request->ip());
if(!$result){
throw new UnauthorizedHttpException('JWTAuth','非法请求域名');
}
......
......@@ -22,19 +22,25 @@ class ThirdPlatformService extends PlatformAbstractService
return $platform ? $platform : [];
}
public function checkUrlFrom($url)
public function checkUrlFrom($ip)
{
$platformInfo = $this->getPlatformInfo();
if(!$platformInfo){
return false;
}
if($platformInfo['platform_type'] == 'self'){
$domain = substr($url, 7);
if(!Str::contains(strtolower((string) $platformInfo['platform_url']), $domain)){
return false;
$params = json_decode($platformInfo['platform_params'],true);
if(!empty($params) && $params['whiteList']){
if(!empty($params['whiteList'])){
foreach($params['whiteList'] as $whiteIp){
if(Str::contains($whiteIp, $ip)){
return true;
}
}
}
}
}
return true;
return false;
}
public function createPlatformToken($platformName)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment