add config check

This commit is contained in:
Dario Rekowski on RockPI 2020-05-12 09:56:53 +00:00
parent 61b520fdef
commit e0aa06744e
2 changed files with 8 additions and 6 deletions

View File

@ -67,11 +67,13 @@ Router::scope('/', function (RouteBuilder $routes) {
return true; return true;
} }
$allowedCaller = Configure::read('API.allowedCaller'); $allowedCaller = Configure::read('API.allowedCaller');
$callerIp = $request->clientIp(); if($allowedCaller && count($allowedCaller) > 0) {
foreach($allowedCaller as $allowed) { $callerIp = $request->clientIp();
$ip = gethostbyname($allowed); foreach($allowedCaller as $allowed) {
if($ip === $callerIp) return true; $ip = gethostbyname($allowed);
} if($ip === $callerIp) return true;
}
}
} }
} }
}); });

@ -1 +1 @@
Subproject commit a04d4769974b9d93ba72e490ed7dca3fbaed768c Subproject commit 21d4a0a5e9a19f251e26c0ae07ce74be2fa99bbf