Add a check for domain and api cidr

This commit is contained in:
Mark Crane 2014-07-29 04:26:32 +00:00
parent 90a177c84a
commit 6e049535e1
2 changed files with 33 additions and 2 deletions

View File

@ -103,8 +103,8 @@ require_once "resources/require.php";
$device_vendor = device::get_vendor($mac);
//keep backwards compatibility
if (strlen($provision["cidr"]) > 0) {
$_SESSION['provision']["cidr"][] = $provision["cidr"];
if (strlen($_SESSION['provision']["cidr"]["text"]) > 0) {
$_SESSION['provision']["cidr"][] = $_SESSION['provision']["cidr"]["text"];
}
//check the cidr range

View File

@ -288,4 +288,35 @@ if ($db_type == "pgsql") {
$domain_uuid = uuid();
}
//check the domain cidr range
if (is_array($_SESSION['domain']["cidr"])) {
$found = false;
foreach($_SESSION['domain']["cidr"] as $cidr) {
if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) {
$found = true;
break;
}
}
if (!$found) {
echo "access denied";
exit;
}
}
//check the api cidr range
if (is_array($_SESSION['api']["cidr"])) {
$found = false;
foreach($_SESSION['api']["cidr"] as $cidr) {
if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) {
$found = true;
break;
}
}
if (!$found) {
unset ($_REQUEST['key']);
unset ($_POST['key']);
unset ($_GET['key']);
}
}
?>