Commit cad80472 authored by hangjun83's avatar hangjun83

优化

parent 4fd03232
...@@ -80,7 +80,7 @@ class Authenticate ...@@ -80,7 +80,7 @@ class Authenticate
throw new UnauthorizedHttpException('JWTAuth','无效的平台token'); throw new UnauthorizedHttpException('JWTAuth','无效的平台token');
} }
//验证平台来源 //验证平台来源
$result = $thirdPlatformService->checkUrlFrom($request->root()); $result = $thirdPlatformService->checkUrlFrom($request->ip());
if(!$result){ if(!$result){
throw new UnauthorizedHttpException('JWTAuth','非法请求域名'); throw new UnauthorizedHttpException('JWTAuth','非法请求域名');
} }
......
...@@ -22,19 +22,25 @@ class ThirdPlatformService extends PlatformAbstractService ...@@ -22,19 +22,25 @@ class ThirdPlatformService extends PlatformAbstractService
return $platform ? $platform : []; return $platform ? $platform : [];
} }
public function checkUrlFrom($url) public function checkUrlFrom($ip)
{ {
$platformInfo = $this->getPlatformInfo(); $platformInfo = $this->getPlatformInfo();
if(!$platformInfo){ if(!$platformInfo){
return false; return false;
} }
if($platformInfo['platform_type'] == 'self'){ if($platformInfo['platform_type'] == 'self'){
$domain = substr($url, 7); $params = json_decode($platformInfo['platform_params'],true);
if(!Str::contains(strtolower((string) $platformInfo['platform_url']), $domain)){ if(!empty($params) && $params['whiteList']){
return false; if(!empty($params['whiteList'])){
foreach($params['whiteList'] as $whiteIp){
if(Str::contains($whiteIp, $ip)){
return true;
}
}
}
} }
} }
return true; return false;
} }
public function createPlatformToken($platformName) 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