summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-10-21 16:02:11 +0200
committerSimon Rettberg2020-10-21 16:02:11 +0200
commitab66db334661477be29d11ac70045e9b2968c82e (patch)
tree8b73cf64965068d40960ed06ff7b92b06d1be30a
parent[serversetup-bwlp-ipxe] Fix UUID validation (diff)
downloadslx-admin-ab66db334661477be29d11ac70045e9b2968c82e.tar.gz
slx-admin-ab66db334661477be29d11ac70045e9b2968c82e.tar.xz
slx-admin-ab66db334661477be29d11ac70045e9b2968c82e.zip
[locationinfo] URLPANEL: Allow black- and whitelist simultaneously
References #3790
-rw-r--r--modules-available/locationinfo/inc/locationinfo.inc.php4
-rw-r--r--modules-available/locationinfo/inc/locationinfohooks.inc.php23
-rw-r--r--modules-available/locationinfo/lang/de/template-tags.json8
-rw-r--r--modules-available/locationinfo/lang/en/template-tags.json8
-rw-r--r--modules-available/locationinfo/page.inc.php16
-rw-r--r--modules-available/locationinfo/templates/page-config-panel-url.html24
6 files changed, 51 insertions, 32 deletions
diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php
index 80b8e66a..6427cc1a 100644
--- a/modules-available/locationinfo/inc/locationinfo.inc.php
+++ b/modules-available/locationinfo/inc/locationinfo.inc.php
@@ -118,8 +118,8 @@ class LocationInfo
}
if ($type === 'URL') {
return array(
- 'iswhitelist' => 0,
- 'urllist' => '',
+ 'whitelist' => '*',
+ 'blacklist' => '',
'insecure-ssl' => 0,
'reload-minutes' => 0,
'split-login' => 0,
diff --git a/modules-available/locationinfo/inc/locationinfohooks.inc.php b/modules-available/locationinfo/inc/locationinfohooks.inc.php
index b0596c10..8e4975e9 100644
--- a/modules-available/locationinfo/inc/locationinfohooks.inc.php
+++ b/modules-available/locationinfo/inc/locationinfohooks.inc.php
@@ -36,8 +36,16 @@ class LocationInfoHooks
ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60);
}
ConfigHolder::add('SLX_BROWSER_URL', $data['url']);
- ConfigHolder::add('SLX_BROWSER_URLLIST', $data['urllist']);
- ConfigHolder::add('SLX_BROWSER_IS_WHITELIST', $data['iswhitelist']);
+ // Mangle non-upgraded panels
+ if (empty($data['blacklist']) && $data['whitelist'] === '*' && !empty($data['urllist'])) {
+ if ($data['iswhitelist']) {
+ $data['whitelist'] = str_replace(' ', "\n", $data['urllist']);
+ } else {
+ $data['blacklist'] = str_replace(' ', "\n", $data['urllist']);
+ }
+ }
+ ConfigHolder::add('SLX_BROWSER_WHITELIST', self::mangleList($data['whitelist']));
+ ConfigHolder::add('SLX_BROWSER_BLACKLIST', self::mangleList($data['blacklist']));
// Additionally, update runmode "isclient" flag depending on whether split-login is allowed or not
if (isset($data['split-login']) && $data['split-login']) {
RunMode::updateClientFlag($machineUuid, 'locationinfo', true);
@@ -76,4 +84,15 @@ class LocationInfoHooks
ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000);
}
+ /**
+ * Turn multiline list into space separated list, removing any
+ * comments (starting with #)
+ * @param string $list
+ * @return string
+ */
+ private static function mangleList($list)
+ {
+ return preg_replace('/\s*(#[^\n]*)?(\n|$)/', ' ', $list);
+ }
+
} \ No newline at end of file
diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json
index 443f5ae2..c9cbe6c8 100644
--- a/modules-available/locationinfo/lang/de/template-tags.json
+++ b/modules-available/locationinfo/lang/de/template-tags.json
@@ -6,6 +6,7 @@
"lang_autoscaleTooltip": "Berechnet anhand der Bildschirmbreite die optimale Anzahl an Tagen, die der Kalender anzeigt",
"lang_backend": "Backend",
"lang_backends": "Backends",
+ "lang_blacklist": "Blacklist",
"lang_bookmarks": "Lesezeichen",
"lang_bookmarksTooltip": "F\u00fcge Lesezeichen hinzu, die der Browser erhalten soll",
"lang_browser": "Browser",
@@ -148,15 +149,14 @@
"lang_typeTooltip": "Legt fest um welchen Server-Typ es sich handelt",
"lang_updateRates": "Aktualisierungsintervall",
"lang_url": "URL",
- "lang_urlBlacklist": "Blacklist",
- "lang_urlListHelp": "Sie k\u00f6nnen hier eine Liste von URLs oder Hostnamen angeben, die dann entweder als Whitelist oder Blacklist interpretiert wird. Unterst\u00fctzt werden die Sonderzeichen '?' (ein beliebiges Zeichen), '*' (beliebig viele Zeichen, au\u00dfer '\/') und '**' (beliebig viele Zeichen, inkl. '\/') als Platzhalter. Beispielangaben sind \"*.wikipedia.org\", \"https:\/\/www.bwlehrpool.de\/**\" oder \"*:\/\/*.uni-freiburg.de\/*.html\".",
+ "lang_urlListHelp": "Sie k\u00f6nnen hier Listen von URLs oder Hostnamen angeben, die dann als Whitelist bzw. Blacklist interpretiert werden. Je nach gew\u00e4hltem Browser hat entweder die Whitelist Vorrang, oder die \"genauere\" Regel. Wenn keine Regel zutrifft, wird der Zugriff erlaubt, es sei denn, es gibt den Eintrag \"*\" in der Blacklist. Je nach verwendetem Browser wird \"*\" als Wildcard an verschiedenen Stellen unterst\u00fctzt. Sie k\u00f6nnen Kommentare hinter oder zwischen den Zeilen mittels \"#\" einleiten. Weitere Informationen finden Sie im bwLehrpool-Wiki.",
"lang_urlPanel": "URL-Panel",
"lang_urlTooltip": "URL die aufgerufen wird",
- "lang_urlWhitelist": "Whitelist",
"lang_useDefault": "Vorgabe f\u00fcr Raum\/Rechner verwenden",
"lang_useRoomplanner": "Rechner z\u00e4hlen",
"lang_vertical": "Vertikaler Modus",
"lang_verticalTooltip": "Legt fest, ob Kalender und Raum \u00fcbereinander angezeigt werden sollen",
"lang_wednesday": "Mittwoch",
- "lang_when": "Wann"
+ "lang_when": "Wann",
+ "lang_whitelist": "Whitelist"
} \ No newline at end of file
diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json
index 0ebae3f9..b4d2a516 100644
--- a/modules-available/locationinfo/lang/en/template-tags.json
+++ b/modules-available/locationinfo/lang/en/template-tags.json
@@ -6,6 +6,7 @@
"lang_autoscaleTooltip": "Calculates the optimum amount of days to show from the display width",
"lang_backend": "Backend",
"lang_backends": "Backends",
+ "lang_blacklist": "Blacklist",
"lang_bookmarks": "Bookmarks",
"lang_bookmarksTooltip": "Add bookmarks to the browser",
"lang_browser": "Browser",
@@ -148,15 +149,14 @@
"lang_typeTooltip": "Defines on which type of server you want to connect to",
"lang_updateRates": "Update rates",
"lang_url": "URL",
- "lang_urlBlacklist": "Blacklist",
- "lang_urlListHelp": "You can specify a list of URLs or host names that will be used as either a blacklist or a whitelist. You can use the special characters '?' to represent any character, '*' to represent any number of characters excluding '\/', or '**' meaning any number of characters, including '\/'. Examples are \"*.wikipedia.org\", \"https:\/\/www.bwlehrpool.de\/**\" or \"*:\/\/*.uni-freiburg.de\/*.html\".",
+ "lang_urlListHelp": "You can specify lists of URLs or hostnames here, which are then interpreted as a whitelist or blacklist. Depending on the selected browser, either the whitelist or the \"more precise\" rule takes precedence. If no rule applies, access will be allowed unless there is an entry \"*\" in the blacklist. Depending on the browser used, \"*\" is supported as a wildcard in different places. You can introduce comments at the end of or between lines using \"#\". Further information can be found in the bwLehrpool-Wiki.",
"lang_urlPanel": "URL panel",
"lang_urlTooltip": "URL which is shown by the panel",
- "lang_urlWhitelist": "Whitelist",
"lang_useDefault": "Use setting from location\/machine",
"lang_useRoomplanner": "Count PCs",
"lang_vertical": "Vertical mode",
"lang_verticalTooltip": "Defines whether the room and calendar are shown above each other",
"lang_wednesday": "Wednesday",
- "lang_when": "When"
+ "lang_when": "When",
+ "lang_whitelist": "Whitelist"
} \ No newline at end of file
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 845398f0..ec7f25ed 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -350,8 +350,8 @@ class Page_LocationInfo extends Page
'url' => Request::post('url', 'https://www.bwlehrpool.de/', 'string'),
'insecure-ssl' => Request::post('insecure-ssl', 0, 'int'),
'reload-minutes' => max(0, Request::post('reloadminutes', 0, 'int')),
- 'iswhitelist' => Request::post('iswhitelist', 0, 'int'),
- 'urllist' => preg_replace("/[\r\n\\s]+/ms", ' ', Request::post('urllist', '', 'string')),
+ 'whitelist' => preg_replace("/[\r\n]+/ms", "\n", Request::post('whitelist', '', 'string')),
+ 'blacklist' => preg_replace("/[\r\n]+/ms", "\n", Request::post('blacklist', '', 'string')),
'split-login' => Request::post('split-login', 0, 'bool'),
'browser' => Request::post('browser', 'slx-browser', 'string'),
'interactive' => Request::post('interactive', '0', 'bool'),
@@ -970,6 +970,14 @@ class Page_LocationInfo extends Page
}
}
+ if (empty($config['blacklist']) && $config['whitelist'] === '*' && !empty($config['urllist'])) {
+ if ($config['iswhitelist']) {
+ $config['whitelist'] = str_replace(' ', "\n", $config['urllist']);
+ } else {
+ $config['blacklist'] = str_replace(' ', "\n", $config['urllist']);
+ }
+ }
+
Render::addTemplate('page-config-panel-url', array(
'new' => $id === 'new',
'uuid' => $id,
@@ -977,8 +985,8 @@ class Page_LocationInfo extends Page
'url' => $config['url'],
'ssl_checked' => $config['insecure-ssl'] ? 'checked' : '',
'reloadminutes' => (int)$config['reload-minutes'],
- 'iswhitelist_' . $config['iswhitelist'] . '_checked' => 'checked',
- 'urllist' => str_replace(' ', "\r\n", $config['urllist']),
+ 'whitelist' => str_replace("\n", "\r\n", $config['whitelist']),
+ 'blacklist' => str_replace("\n", "\r\n", $config['blacklist']),
'split-login_checked' => $config['split-login'] ? 'checked' : '',
'browser' => $config['browser'],
'interactive_checked' => $config['interactive'] ? 'checked' : '',
diff --git a/modules-available/locationinfo/templates/page-config-panel-url.html b/modules-available/locationinfo/templates/page-config-panel-url.html
index 8d4d7148..eb84b2d3 100644
--- a/modules-available/locationinfo/templates/page-config-panel-url.html
+++ b/modules-available/locationinfo/templates/page-config-panel-url.html
@@ -113,25 +113,17 @@
<div class="list-group-item">
<div class="row">
- <div class="col-sm-3">
- <div class="radio">
- <input type="radio" name="iswhitelist" value="1" {{iswhitelist_1_checked}} id="iswhitelist1" class="form-control">
- <label for="iswhitelist1">
- {{lang_urlWhitelist}}
- </label>
- </div>
- <div class="radio">
- <input type="radio" name="iswhitelist" value="0" {{iswhitelist_0_checked}} id="iswhitelist0" class="form-control">
- <label for="iswhitelist0">
- {{lang_urlBlacklist}}
- </label>
- </div>
+ <div class="col-sm-6">
+ <label for="whitelist">{{lang_whitelist}}</label>
+ <textarea id="whitelist" name="whitelist" rows="10" class="form-control">{{whitelist}}</textarea>
</div>
- <div class="col-sm-7">
- <textarea name="urllist" rows="10" class="form-control">{{urllist}}</textarea>
+ <div class="col-sm-6">
+ <label for="blacklist">{{lang_blacklist}}</label>
+ <textarea id="blacklist" name="blacklist" rows="10" class="form-control">{{blacklist}}</textarea>
+ </div>
+ <div class="col-sm-12">
<p>{{lang_urlListHelp}}</p>
</div>
- <div class="col-sm-2"></div>
</div>
</div>