refactor: move tlsEnabled to Settings
newkey: security/tlsEnabled <= General/cryptoEnabled remove tlsEnabled from appconfig
This commit is contained in:
parent
4c6195cc5d
commit
2721de220a
11 changed files with 25 additions and 41 deletions
|
|
@ -157,7 +157,7 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
||||||
updateSize();
|
updateSize();
|
||||||
|
|
||||||
// Force generation of SHA256 for the localhost
|
// Force generation of SHA256 for the localhost
|
||||||
if (m_appConfig.tlsEnabled()) {
|
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||||
if (!QFile::exists(localFingerprintDb())) {
|
if (!QFile::exists(localFingerprintDb())) {
|
||||||
regenerateLocalFingerprints();
|
regenerateLocalFingerprints();
|
||||||
return;
|
return;
|
||||||
|
|
@ -591,7 +591,7 @@ void MainWindow::updateSecurityIcon(bool visible)
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool secureSocket = m_appConfig.tlsEnabled();
|
bool secureSocket = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||||
|
|
||||||
const auto txt =
|
const auto txt =
|
||||||
secureSocket ? tr("%1 Encryption Enabled").arg(m_coreProcess.secureSocketVersion()) : tr("Encryption Disabled");
|
secureSocket ? tr("%1 Encryption Enabled").arg(m_coreProcess.secureSocketVersion()) : tr("Encryption Disabled");
|
||||||
|
|
@ -1018,7 +1018,8 @@ QString MainWindow::getIPAddresses() const
|
||||||
|
|
||||||
void MainWindow::updateLocalFingerprint()
|
void MainWindow::updateLocalFingerprint()
|
||||||
{
|
{
|
||||||
m_btnFingerprint->setVisible(m_appConfig.tlsEnabled() && QFile::exists(localFingerprintDb()));
|
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||||
|
m_btnFingerprint->setVisible(tlsEnabled && QFile::exists(localFingerprintDb()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::autoAddScreen(const QString name)
|
void MainWindow::autoAddScreen(const QString name)
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ void SettingsDialog::accept()
|
||||||
m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked());
|
m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked());
|
||||||
m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text());
|
m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text());
|
||||||
m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt());
|
m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt());
|
||||||
m_appConfig.setTlsEnabled(ui->groupSecurity->isChecked());
|
Settings::setValue(Settings::Security::TlsEnabled, ui->groupSecurity->isChecked());
|
||||||
m_appConfig.setLanguageSync(ui->cbLanguageSync->isChecked());
|
m_appConfig.setLanguageSync(ui->cbLanguageSync->isChecked());
|
||||||
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
|
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
|
||||||
m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked());
|
m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked());
|
||||||
|
|
@ -218,7 +218,7 @@ void SettingsDialog::updateTlsControls()
|
||||||
ui->comboTlsKeyLength->setCurrentIndex(ui->comboTlsKeyLength->findText(keyLengthText));
|
ui->comboTlsKeyLength->setCurrentIndex(ui->comboTlsKeyLength->findText(keyLengthText));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto tlsEnabled = m_tlsUtility.isEnabled();
|
const auto tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||||
const auto writable = m_appConfig.isActiveScopeWritable();
|
const auto writable = m_appConfig.isActiveScopeWritable();
|
||||||
const auto enabled = writable && tlsEnabled;
|
const auto enabled = writable && tlsEnabled;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ QVariant Settings::defaultValue(const QString &key)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((key == Gui::CloseToTray) || (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)
|
if ((key == Gui::CloseToTray) || (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)
|
||||||
|| (key == Gui::CloseReminder)) {
|
|| (key == Gui::CloseReminder) || (key == Security::TlsEnabled)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ public:
|
||||||
inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon");
|
inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon");
|
||||||
inline static const auto WindowGeometry = QStringLiteral("gui/windowGeometry");
|
inline static const auto WindowGeometry = QStringLiteral("gui/windowGeometry");
|
||||||
};
|
};
|
||||||
|
struct Security
|
||||||
|
{
|
||||||
|
inline static const auto TlsEnabled = QStringLiteral("security/tlsEnabled");
|
||||||
|
};
|
||||||
|
|
||||||
static Settings *instance();
|
static Settings *instance();
|
||||||
static void setSettingFile(const QString &settingsFile = QString());
|
static void setSettingFile(const QString &settingsFile = QString());
|
||||||
|
|
@ -85,6 +89,7 @@ private:
|
||||||
, Gui::LogExpanded
|
, Gui::LogExpanded
|
||||||
, Gui::SymbolicTrayIcon
|
, Gui::SymbolicTrayIcon
|
||||||
, Gui::WindowGeometry
|
, Gui::WindowGeometry
|
||||||
|
, Security::TlsEnabled
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,10 @@ const char *const AppConfig::m_SettingsName[] = {
|
||||||
"", // 7 statedBefore moved to deskflow settings
|
"", // 7 statedBefore moved to deskflow settings
|
||||||
"elevateMode",
|
"elevateMode",
|
||||||
"elevateModeEnum",
|
"elevateModeEnum",
|
||||||
"", // 10 = edition, obsolete (using serial key instead)
|
"", // 10 = edition, obsolete (using serial key instead)
|
||||||
"cryptoEnabled", // 11 = kTlsEnabled (retain legacy string value)
|
"", // 11 = kTlsEnabled (retain legacy string value) Moved to Settings
|
||||||
"", // 12 AutoHide, moved to Settings
|
"", // 12 AutoHide, moved to Settings
|
||||||
"", // 13 = serialKey, obsolete
|
"", // 13 = serialKey, obsolete
|
||||||
"lastVersion",
|
"lastVersion",
|
||||||
"", // 15 = lastExpiringWarningTime, obsolete
|
"", // 15 = lastExpiringWarningTime, obsolete
|
||||||
"", // 16 = activationHasRun, obsolete
|
"", // 16 = activationHasRun, obsolete
|
||||||
|
|
@ -131,7 +131,6 @@ void AppConfig::recallFromCurrentScope()
|
||||||
m_LanguageSync = getFromCurrentScope(kLanguageSync, m_LanguageSync).toBool();
|
m_LanguageSync = getFromCurrentScope(kLanguageSync, m_LanguageSync).toBool();
|
||||||
m_InvertScrollDirection = getFromCurrentScope(kInvertScrollDirection, m_InvertScrollDirection).toBool();
|
m_InvertScrollDirection = getFromCurrentScope(kInvertScrollDirection, m_InvertScrollDirection).toBool();
|
||||||
m_EnableService = getFromCurrentScope(kEnableService, m_EnableService).toBool();
|
m_EnableService = getFromCurrentScope(kEnableService, m_EnableService).toBool();
|
||||||
m_TlsEnabled = getFromCurrentScope(kTlsEnabled, m_TlsEnabled).toBool();
|
|
||||||
m_TlsCertPath = getFromCurrentScope(kTlsCertPath, m_TlsCertPath).toString();
|
m_TlsCertPath = getFromCurrentScope(kTlsCertPath, m_TlsCertPath).toString();
|
||||||
m_TlsKeyLength = getFromCurrentScope(kTlsKeyLength, m_TlsKeyLength).toInt();
|
m_TlsKeyLength = getFromCurrentScope(kTlsKeyLength, m_TlsKeyLength).toInt();
|
||||||
m_RequireClientCert = getFromCurrentScope(kRequireClientCert, m_RequireClientCert).toBool();
|
m_RequireClientCert = getFromCurrentScope(kRequireClientCert, m_RequireClientCert).toBool();
|
||||||
|
|
@ -173,7 +172,6 @@ void AppConfig::commit()
|
||||||
setInCurrentScope(kLogFilename, m_LogFilename);
|
setInCurrentScope(kLogFilename, m_LogFilename);
|
||||||
setInCurrentScope(kElevateMode, static_cast<int>(m_ElevateMode));
|
setInCurrentScope(kElevateMode, static_cast<int>(m_ElevateMode));
|
||||||
setInCurrentScope(kElevateModeLegacy, m_ElevateMode == ElevateMode::kAlways);
|
setInCurrentScope(kElevateModeLegacy, m_ElevateMode == ElevateMode::kAlways);
|
||||||
setInCurrentScope(kTlsEnabled, m_TlsEnabled);
|
|
||||||
setInCurrentScope(kLastVersion, m_LastVersion);
|
setInCurrentScope(kLastVersion, m_LastVersion);
|
||||||
setInCurrentScope(kUseExternalConfig, m_UseExternalConfig);
|
setInCurrentScope(kUseExternalConfig, m_UseExternalConfig);
|
||||||
setInCurrentScope(kConfigFile, m_ConfigFile);
|
setInCurrentScope(kConfigFile, m_ConfigFile);
|
||||||
|
|
@ -450,11 +448,6 @@ ElevateMode AppConfig::elevateMode() const
|
||||||
return m_ElevateMode;
|
return m_ElevateMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppConfig::tlsEnabled() const
|
|
||||||
{
|
|
||||||
return m_TlsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppConfig::invertScrollDirection() const
|
bool AppConfig::invertScrollDirection() const
|
||||||
{
|
{
|
||||||
return m_InvertScrollDirection;
|
return m_InvertScrollDirection;
|
||||||
|
|
@ -528,15 +521,6 @@ const QString &AppConfig::serverHostname() const
|
||||||
// Begin setters
|
// Begin setters
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void AppConfig::setTlsEnabled(bool value)
|
|
||||||
{
|
|
||||||
// we purposefully do not set the 'tls changed' flag when enabling/disabling
|
|
||||||
// tls, since that would cause the certificate to regenerate, which could get
|
|
||||||
// pretty annoying.
|
|
||||||
|
|
||||||
m_TlsEnabled = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppConfig::setTlsCertPath(const QString &value)
|
void AppConfig::setTlsCertPath(const QString &value)
|
||||||
{
|
{
|
||||||
if (m_TlsCertPath != value) {
|
if (m_TlsCertPath != value) {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ private:
|
||||||
kElevateModeLegacy = 8,
|
kElevateModeLegacy = 8,
|
||||||
kElevateMode = 9,
|
kElevateMode = 9,
|
||||||
// 10 = edition, obsolete (related to obsolete licensing)
|
// 10 = edition, obsolete (related to obsolete licensing)
|
||||||
kTlsEnabled = 11,
|
// 11 = tlsEnagled moved to Settigns
|
||||||
// 12 = auto hide, Moved to Settings
|
// 12 = auto hide, Moved to Settings
|
||||||
// 13 = serial key, obsolete
|
// 13 = serial key, obsolete
|
||||||
kLastVersion = 14,
|
kLastVersion = 14,
|
||||||
|
|
@ -135,7 +135,6 @@ public:
|
||||||
IConfigScopes &scopes() const override;
|
IConfigScopes &scopes() const override;
|
||||||
ProcessMode processMode() const override;
|
ProcessMode processMode() const override;
|
||||||
ElevateMode elevateMode() const override;
|
ElevateMode elevateMode() const override;
|
||||||
bool tlsEnabled() const override;
|
|
||||||
QString tlsCertPath() const override;
|
QString tlsCertPath() const override;
|
||||||
int tlsKeyLength() const override;
|
int tlsKeyLength() const override;
|
||||||
QString logLevelText() const override;
|
QString logLevelText() const override;
|
||||||
|
|
@ -180,7 +179,6 @@ public:
|
||||||
void setLogToFile(bool b) override;
|
void setLogToFile(bool b) override;
|
||||||
void setLogFilename(const QString &s) override;
|
void setLogFilename(const QString &s) override;
|
||||||
void setElevateMode(ElevateMode em) override;
|
void setElevateMode(ElevateMode em) override;
|
||||||
void setTlsEnabled(bool e) override;
|
|
||||||
void setInvertScrollDirection(bool b) override;
|
void setInvertScrollDirection(bool b) override;
|
||||||
void setLanguageSync(bool b) override;
|
void setLanguageSync(bool b) override;
|
||||||
void setPreventSleep(bool b) override;
|
void setPreventSleep(bool b) override;
|
||||||
|
|
@ -282,7 +280,6 @@ private:
|
||||||
bool m_LogToFile = false;
|
bool m_LogToFile = false;
|
||||||
QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile;
|
QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile;
|
||||||
ElevateMode m_ElevateMode = deskflow::gui::kDefaultElevateMode;
|
ElevateMode m_ElevateMode = deskflow::gui::kDefaultElevateMode;
|
||||||
bool m_TlsEnabled = true;
|
|
||||||
QString m_LastVersion = "";
|
QString m_LastVersion = "";
|
||||||
bool m_InvertScrollDirection = false;
|
bool m_InvertScrollDirection = false;
|
||||||
bool m_LanguageSync = true;
|
bool m_LanguageSync = true;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ public:
|
||||||
virtual IConfigScopes &scopes() const = 0;
|
virtual IConfigScopes &scopes() const = 0;
|
||||||
virtual QString tlsCertPath() const = 0;
|
virtual QString tlsCertPath() const = 0;
|
||||||
virtual int tlsKeyLength() const = 0;
|
virtual int tlsKeyLength() const = 0;
|
||||||
virtual bool tlsEnabled() const = 0;
|
|
||||||
virtual ProcessMode processMode() const = 0;
|
virtual ProcessMode processMode() const = 0;
|
||||||
virtual ElevateMode elevateMode() const = 0;
|
virtual ElevateMode elevateMode() const = 0;
|
||||||
virtual QString logLevelText() const = 0;
|
virtual QString logLevelText() const = 0;
|
||||||
|
|
@ -74,7 +73,6 @@ public:
|
||||||
virtual void setPreventSleep(bool preventSleep) = 0;
|
virtual void setPreventSleep(bool preventSleep) = 0;
|
||||||
virtual void setTlsCertPath(const QString &tlsCertPath) = 0;
|
virtual void setTlsCertPath(const QString &tlsCertPath) = 0;
|
||||||
virtual void setTlsKeyLength(int tlsKeyLength) = 0;
|
virtual void setTlsKeyLength(int tlsKeyLength) = 0;
|
||||||
virtual void setTlsEnabled(bool tlsEnabled) = 0;
|
|
||||||
virtual void setLanguageSync(bool languageSync) = 0;
|
virtual void setLanguageSync(bool languageSync) = 0;
|
||||||
virtual void setInvertScrollDirection(bool invertScrollDirection) = 0;
|
virtual void setInvertScrollDirection(bool invertScrollDirection) = 0;
|
||||||
virtual void setEnableService(bool enableService) = 0;
|
virtual void setEnableService(bool enableService) = 0;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "CoreProcess.h"
|
#include "CoreProcess.h"
|
||||||
|
|
||||||
#include "common/constants.h"
|
#include "common/Settings.h"
|
||||||
#include "gui/config/IAppConfig.h"
|
#include "gui/config/IAppConfig.h"
|
||||||
#include "gui/core/CoreTool.h"
|
#include "gui/core/CoreTool.h"
|
||||||
#include "gui/ipc/DaemonIpcClient.h"
|
#include "gui/ipc/DaemonIpcClient.h"
|
||||||
|
|
@ -500,7 +500,7 @@ bool CoreProcess::addGenericArgs(QStringList &args, const ProcessMode processMod
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_appConfig.tlsEnabled()) {
|
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||||
args << "--enable-crypto";
|
args << "--enable-crypto";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -555,7 +555,7 @@ bool CoreProcess::addServerArgs(QStringList &args, QString &app)
|
||||||
// bizarrely, the tls cert path arg was being given to the core client.
|
// bizarrely, the tls cert path arg was being given to the core client.
|
||||||
// since it's not clear why (it is only needed for the server), this has now
|
// since it's not clear why (it is only needed for the server), this has now
|
||||||
// been moved to server args.
|
// been moved to server args.
|
||||||
if (m_appConfig.tlsEnabled()) {
|
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||||
TlsUtility tlsUtility(m_appConfig);
|
TlsUtility tlsUtility(m_appConfig);
|
||||||
if (!tlsUtility.persistCertificate()) {
|
if (!tlsUtility.persistCertificate()) {
|
||||||
qCritical("failed to persist tls certificate");
|
qCritical("failed to persist tls certificate");
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "ServerConnection.h"
|
#include "ServerConnection.h"
|
||||||
|
|
||||||
#include "ServerMessage.h"
|
#include "ServerMessage.h"
|
||||||
|
#include "common/Settings.h"
|
||||||
#include "gui/config/ServerConfigDialogState.h"
|
#include "gui/config/ServerConfigDialogState.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
|
|
@ -94,8 +95,9 @@ void ServerConnection::handleNewClient(const QString &clientName)
|
||||||
Q_EMIT messageShowing();
|
Q_EMIT messageShowing();
|
||||||
|
|
||||||
m_messageShowing = true;
|
m_messageShowing = true;
|
||||||
|
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||||
const auto result =
|
const auto result =
|
||||||
m_pDeps->showNewClientPrompt(m_pParent, clientName, m_appConfig.tlsEnabled() && m_appConfig.requireClientCerts());
|
m_pDeps->showNewClientPrompt(m_pParent, clientName, tlsEnabled && m_appConfig.requireClientCerts());
|
||||||
m_messageShowing = false;
|
m_messageShowing = false;
|
||||||
|
|
||||||
if (result == Add) {
|
if (result == Add) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include "TlsUtility.h"
|
#include "TlsUtility.h"
|
||||||
|
|
||||||
#include "TlsCertificate.h"
|
#include "TlsCertificate.h"
|
||||||
|
#include "common/Settings.h"
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
@ -19,8 +19,7 @@ TlsUtility::TlsUtility(const IAppConfig &appConfig) : m_appConfig(appConfig)
|
||||||
|
|
||||||
bool TlsUtility::isEnabled() const
|
bool TlsUtility::isEnabled() const
|
||||||
{
|
{
|
||||||
const auto &config = m_appConfig;
|
return Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||||
return config.tlsEnabled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TlsUtility::generateCertificate()
|
bool TlsUtility::generateCertificate()
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ public:
|
||||||
MOCK_METHOD(deskflow::gui::IConfigScopes &, scopes, (), (const, override));
|
MOCK_METHOD(deskflow::gui::IConfigScopes &, scopes, (), (const, override));
|
||||||
MOCK_METHOD(QString, tlsCertPath, (), (const, override));
|
MOCK_METHOD(QString, tlsCertPath, (), (const, override));
|
||||||
MOCK_METHOD(int, tlsKeyLength, (), (const, override));
|
MOCK_METHOD(int, tlsKeyLength, (), (const, override));
|
||||||
MOCK_METHOD(bool, tlsEnabled, (), (const, override));
|
|
||||||
MOCK_METHOD(ProcessMode, processMode, (), (const, override));
|
MOCK_METHOD(ProcessMode, processMode, (), (const, override));
|
||||||
MOCK_METHOD(ElevateMode, elevateMode, (), (const, override));
|
MOCK_METHOD(ElevateMode, elevateMode, (), (const, override));
|
||||||
MOCK_METHOD(QString, logLevelText, (), (const, override));
|
MOCK_METHOD(QString, logLevelText, (), (const, override));
|
||||||
|
|
@ -75,7 +74,6 @@ public:
|
||||||
MOCK_METHOD(void, setPreventSleep, (bool preventSleep), (override));
|
MOCK_METHOD(void, setPreventSleep, (bool preventSleep), (override));
|
||||||
MOCK_METHOD(void, setTlsCertPath, (const QString &tlsCertPath), (override));
|
MOCK_METHOD(void, setTlsCertPath, (const QString &tlsCertPath), (override));
|
||||||
MOCK_METHOD(void, setTlsKeyLength, (int tlsKeyLength), (override));
|
MOCK_METHOD(void, setTlsKeyLength, (int tlsKeyLength), (override));
|
||||||
MOCK_METHOD(void, setTlsEnabled, (bool tlsEnabled), (override));
|
|
||||||
MOCK_METHOD(void, setLanguageSync, (bool languageSync), (override));
|
MOCK_METHOD(void, setLanguageSync, (bool languageSync), (override));
|
||||||
MOCK_METHOD(void, setInvertScrollDirection, (bool invertScrollDirection), (override));
|
MOCK_METHOD(void, setInvertScrollDirection, (bool invertScrollDirection), (override));
|
||||||
MOCK_METHOD(void, setEnableService, (bool enableService), (override));
|
MOCK_METHOD(void, setEnableService, (bool enableService), (override));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue