Browse Source

Merge pull request #9185 from Chocobo1/cache

Cache more preference values in WebApplication
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
837308deb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/webui/webapplication.cpp
  2. 7
      src/webui/webapplication.h

17
src/webui/webapplication.cpp

@ -53,7 +53,6 @@ @@ -53,7 +53,6 @@
#include "base/utils/bytearray.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/net.h"
#include "base/utils/random.h"
#include "base/utils/string.h"
#include "api/apierror.h"
@ -426,9 +425,6 @@ void WebApplication::configure() @@ -426,9 +425,6 @@ void WebApplication::configure()
{
const auto pref = Preferences::instance();
m_domainList = pref->getServerDomains().split(';', QString::SkipEmptyParts);
std::for_each(m_domainList.begin(), m_domainList.end(), [](QString &entry) { entry = entry.trimmed(); });
const QString rootFolder = Utils::Fs::expandPathAbs(
!pref->isAltWebUiEnabled() ? WWW_FOLDER : pref->getWebUiRootFolder());
if (rootFolder != m_rootFolder) {
@ -442,6 +438,13 @@ void WebApplication::configure() @@ -442,6 +438,13 @@ void WebApplication::configure()
m_translatedFiles.clear();
}
m_isLocalAuthEnabled = pref->isWebUiLocalAuthEnabled();
m_isAuthSubnetWhitelistEnabled = pref->isWebUiAuthSubnetWhitelistEnabled();
m_authSubnetWhitelist = pref->getWebUiAuthSubnetWhitelist();
m_domainList = pref->getServerDomains().split(';', QString::SkipEmptyParts);
std::for_each(m_domainList.begin(), m_domainList.end(), [](QString &entry) { entry = entry.trimmed(); });
m_isClickjackingProtectionEnabled = pref->isWebUiClickjackingProtectionEnabled();
m_isCSRFProtectionEnabled = pref->isWebUiCSRFProtectionEnabled();
m_isHttpsEnabled = pref->isWebUiHttpsEnabled();
@ -619,11 +622,9 @@ QString WebApplication::generateSid() const @@ -619,11 +622,9 @@ QString WebApplication::generateSid() const
bool WebApplication::isAuthNeeded()
{
qDebug("Checking auth rules against client address %s", qPrintable(m_env.clientAddress.toString()));
const Preferences *pref = Preferences::instance();
if (!pref->isWebUiLocalAuthEnabled() && Utils::Net::isLoopbackAddress(m_env.clientAddress))
if (!m_isLocalAuthEnabled && Utils::Net::isLoopbackAddress(m_env.clientAddress))
return false;
if (pref->isWebUiAuthSubnetWhitelistEnabled() && Utils::Net::isIPInRange(m_env.clientAddress, pref->getWebUiAuthSubnetWhitelist()))
if (m_isAuthSubnetWhitelistEnabled && Utils::Net::isIPInRange(m_env.clientAddress, m_authSubnetWhitelist))
return false;
return true;
}

7
src/webui/webapplication.h

@ -39,6 +39,7 @@ @@ -39,6 +39,7 @@
#include "base/http/irequesthandler.h"
#include "base/http/responsebuilder.h"
#include "base/http/types.h"
#include "base/utils/net.h"
#include "base/utils/version.h"
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 0, 1};
@ -133,7 +134,6 @@ private: @@ -133,7 +134,6 @@ private:
QSet<QString> m_publicAPIs;
bool m_isAltUIUsed = false;
QString m_rootFolder;
QStringList m_domainList;
struct TranslatedFile
{
@ -143,7 +143,12 @@ private: @@ -143,7 +143,12 @@ private:
QMap<QString, TranslatedFile> m_translatedFiles;
QString m_currentLocale;
bool m_isLocalAuthEnabled;
bool m_isAuthSubnetWhitelistEnabled;
QList<Utils::Net::Subnet> m_authSubnetWhitelist;
// security related
QStringList m_domainList;
bool m_isClickjackingProtectionEnabled;
bool m_isCSRFProtectionEnabled;
bool m_isHttpsEnabled;

Loading…
Cancel
Save