From 2ebc6a056e0842d05546f8a271032664204234ac Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Sun, 21 Oct 2018 23:37:53 -0400 Subject: [PATCH] Add "Use alternative Web UI" option --- src/webui/api/appcontroller.cpp | 8 +++++++ .../www/private/preferences_content.html | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index c6fc38d65..1eb5c4fd0 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -217,6 +217,9 @@ void AppController::preferencesAction() for (const Utils::Net::Subnet &subnet : asConst(pref->getWebUiAuthSubnetWhitelist())) authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet); data["bypass_auth_subnet_whitelist"] = authSubnetWhitelistStringList.join("\n"); + // Use alternative Web UI + data["alternative_webui_enabled"] = pref->isAltWebUiEnabled(); + data["alternative_webui_path"] = pref->getWebUiRootFolder(); // Security data["web_ui_clickjacking_protection_enabled"] = pref->isWebUiClickjackingProtectionEnabled(); data["web_ui_csrf_protection_enabled"] = pref->isWebUiCSRFProtectionEnabled(); @@ -518,6 +521,11 @@ void AppController::setPreferencesAction() // recognize new lines and commas as delimiters pref->setWebUiAuthSubnetWhitelist(m["bypass_auth_subnet_whitelist"].toString().split(QRegularExpression("\n|,"), QString::SkipEmptyParts)); } + // Use alternative Web UI + if ((it = m.find(QLatin1String("alternative_webui_enabled"))) != m.constEnd()) + pref->setAltWebUiEnabled(it.value().toBool()); + if ((it = m.find(QLatin1String("alternative_webui_path"))) != m.constEnd()) + pref->setWebUiRootFolder(it.value().toString()); // Security if (m.contains("web_ui_clickjacking_protection_enabled")) pref->setWebUiClickjackingProtectionEnabled(m["web_ui_clickjacking_protection_enabled"].toBool()); diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 4e7296f8a..6bcd0378d 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -705,6 +705,15 @@ +
+ + +
+ + +
+
+
QBT_TR(Security)QBT_TR[CONTEXT=OptionsDialog]
@@ -1005,6 +1014,11 @@ $('bypass_auth_subnet_whitelist_textarea').setProperty('disabled', !isBypassAuthSubnetWhitelistEnabled); }; + updateAlternativeWebUISettings = function() { + var isUseAlternativeWebUIEnabled = $('use_alt_webui_checkbox').getProperty('checked'); + $('webui_files_location_textarea').setProperty('disabled', !isUseAlternativeWebUIEnabled); + }; + updateHostHeaderValidationSettings = function() { var isHostHeaderValidationEnabled = $('host_header_validation_checkbox').getProperty('checked'); $('webui_domain_textarea').setProperty('disabled', !isHostHeaderValidationEnabled); @@ -1286,6 +1300,11 @@ $('bypass_auth_subnet_whitelist_textarea').setProperty('value', pref.bypass_auth_subnet_whitelist); updateBypasssAuthSettings(); + // Use alternative Web UI + $('use_alt_webui_checkbox').setProperty('checked', pref.alternative_webui_enabled); + $('webui_files_location_textarea').setProperty('value', pref.alternative_webui_path); + updateAlternativeWebUISettings(); + // Security $('clickjacking_protection_checkbox').setProperty('checked', pref.web_ui_clickjacking_protection_enabled); $('csrf_protection_checkbox').setProperty('checked', pref.web_ui_csrf_protection_enabled); @@ -1590,6 +1609,10 @@ settings.set('bypass_auth_subnet_whitelist_enabled', $('bypass_auth_subnet_whitelist_checkbox').getProperty('checked')); settings.set('bypass_auth_subnet_whitelist', $('bypass_auth_subnet_whitelist_textarea').getProperty('value')); + // Use alternative Web UI + settings.set('alternative_webui_enabled', $('use_alt_webui_checkbox').getProperty('checked')); + settings.set('alternative_webui_path', $('webui_files_location_textarea').getProperty('value')); + settings.set('web_ui_clickjacking_protection_enabled', $('clickjacking_protection_checkbox').getProperty('checked')); settings.set('web_ui_csrf_protection_enabled', $('csrf_protection_checkbox').getProperty('checked')); settings.set('web_ui_host_header_validation_enabled', $('host_header_validation_checkbox').getProperty('checked'));