fix saving of apikey allowed-from setting

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-10-09 10:37:27 +02:00
parent 854986abcb
commit b6e4dbd70a
4 changed files with 5 additions and 5 deletions

View File

@@ -94,7 +94,7 @@ if ($action == 'delete') {
unset ($ip_list[$idx]); unset ($ip_list[$idx]);
} }
} }
$ip_list = array_map('inet_pton', $ip_list); $ip_list = array_map('inet_ntop', array_map('inet_pton', $ip_list));
$allowed_from = implode(",", array_unique($ip_list)); $allowed_from = implode(",", array_unique($ip_list));
if ($valid_until <= 0 || !is_numeric($valid_until)) { if ($valid_until <= 0 || !is_numeric($valid_until)) {

View File

@@ -62,9 +62,9 @@ class FroxlorRPC
if ($result) { if ($result) {
if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == -1 || $result['valid_until'] >= time())) { if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == -1 || $result['valid_until'] >= time())) {
if (!empty($result['allowed_from'])) { if (!empty($result['allowed_from'])) {
// @todo allow specification and validating of whole subnets later
$ip_list = explode(",", $result['allowed_from']); $ip_list = explode(",", $result['allowed_from']);
$ip_list = array_map('inet_pton', $ip_list); $access_ip = inet_ntop(inet_pton($_SERVER['REMOTE_ADDR']));
$access_ip = inet_pton($_SERVER['REMOTE_ADDR']);
if (in_array($access_ip, $ip_list)) { if (in_array($access_ip, $ip_list)) {
return true; return true;
} }

View File

@@ -2140,7 +2140,7 @@ $lng['apikeys']['apikey_removed'] = 'The api key with the id #%s has been remove
$lng['apikeys']['apikey_added'] = 'A new api key has been generated successfully'; $lng['apikeys']['apikey_added'] = 'A new api key has been generated successfully';
$lng['apikeys']['clicktoview'] = 'Click to view'; $lng['apikeys']['clicktoview'] = 'Click to view';
$lng['apikeys']['allowed_from'] = 'Allowed from'; $lng['apikeys']['allowed_from'] = 'Allowed from';
$lng['apikeys']['allowed_from_help'] = 'Comma separated list of ip addresses. Default empty.'; $lng['apikeys']['allowed_from_help'] = 'Comma separated list of ip addresses. Default empty.<br>Specifying a subgnet e.g. 192.168.1.1/24 is currently not supported.';
$lng['apikeys']['valid_until'] = 'Valid until'; $lng['apikeys']['valid_until'] = 'Valid until';
$lng['apikeys']['valid_until_help'] = 'Date until valid, format YYYY-MM-DD'; $lng['apikeys']['valid_until_help'] = 'Date until valid, format YYYY-MM-DD';
$lng['serversettings']['enable_api']['title'] = 'Enable external API usage'; $lng['serversettings']['enable_api']['title'] = 'Enable external API usage';

View File

@@ -1788,7 +1788,7 @@ $lng['apikeys']['no_api_keys'] = 'Keine API Keys gefunden';
$lng['apikeys']['key_add'] = 'API Key hinzufügen'; $lng['apikeys']['key_add'] = 'API Key hinzufügen';
$lng['apikeys']['apikey_removed'] = 'Der API Key mit der ID #%s wurde erfolgreich gelöscht.'; $lng['apikeys']['apikey_removed'] = 'Der API Key mit der ID #%s wurde erfolgreich gelöscht.';
$lng['apikeys']['allowed_from'] = 'Erlaube Zugriff von'; $lng['apikeys']['allowed_from'] = 'Erlaube Zugriff von';
$lng['apikeys']['allowed_from_help'] = 'Komma getrennte Liste von IPs. Standard ist leer.'; $lng['apikeys']['allowed_from_help'] = 'Komma getrennte Liste von IPs. Standard ist leer.<br>Angabe von Subnetzen z.B. 192.168.1.1/24 wird derzeit nicht unterstützt.';
$lng['apikeys']['valid_until'] = 'Gültig bis'; $lng['apikeys']['valid_until'] = 'Gültig bis';
$lng['apikeys']['valid_until_help'] = 'Datum Gültigkeitsende, Format JJJJ-MM-TT'; $lng['apikeys']['valid_until_help'] = 'Datum Gültigkeitsende, Format JJJJ-MM-TT';
$lng['serversettings']['enable_api']['title'] = 'Aktiviere externe API Nutzung'; $lng['serversettings']['enable_api']['title'] = 'Aktiviere externe API Nutzung';