SimpleCrypt password jamming is now optional
This commit is contained in:
parent
85ff6c25ba
commit
9a44ae1fa5
@ -35,6 +35,7 @@ option(WITH_KWALLET "Build KWallet support module" ON)
|
||||
option(WITH_KIO "Build KIO support module" ON)
|
||||
option(WITH_KCONFIG "Build KConfig support module" ON)
|
||||
option(WITH_OMEMO "Build OMEMO support module" OFF) #it should be off by default untill I sort the problems out
|
||||
option(WITH_SIMPLE_CRYPT "Builds with SimpleCrypt to obfuscate password" ON)
|
||||
|
||||
# Dependencies
|
||||
## Qt
|
||||
@ -176,13 +177,18 @@ target_link_libraries(squawk
|
||||
Qt${QT_VERSION_MAJOR}::Xml
|
||||
LMDBAL::LMDBAL
|
||||
QXmpp::QXmpp
|
||||
simpleCrypt
|
||||
)
|
||||
|
||||
if (WITH_OMEMO)
|
||||
target_link_libraries(squawk PRIVATE QXmpp::Omemo)
|
||||
endif ()
|
||||
|
||||
if (WITH_SIMPLE_CRYPT)
|
||||
target_compile_definitions(squawk PRIVATE WITH_SIMPLE_CRYPT)
|
||||
add_subdirectory(external/simpleCrypt)
|
||||
target_link_libraries(squawk PRIVATE simpleCrypt)
|
||||
endif ()
|
||||
|
||||
## Link thread libraries on Linux
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
@ -219,7 +225,6 @@ add_compile_definitions(PLUGIN_PATH="${PLUGIN_PATH}")
|
||||
|
||||
add_subdirectory(main)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(external/simpleCrypt)
|
||||
add_subdirectory(packaging)
|
||||
add_subdirectory(plugins)
|
||||
add_subdirectory(resources)
|
||||
|
@ -22,6 +22,10 @@
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#ifdef WITH_SIMPLE_CRYPT
|
||||
#include "external/simpleCrypt/simplecrypt.h"
|
||||
#endif
|
||||
|
||||
Core::Squawk::Squawk(QObject* parent):
|
||||
QObject(parent),
|
||||
accounts(),
|
||||
@ -71,7 +75,6 @@ void Core::Squawk::stop() {
|
||||
QSettings settings;
|
||||
settings.beginGroup("core");
|
||||
settings.beginWriteArray("accounts");
|
||||
SimpleCrypt crypto(passwordHash);
|
||||
for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
Account* acc = accounts[i];
|
||||
@ -84,7 +87,13 @@ void Core::Squawk::stop() {
|
||||
password = acc->getPassword();
|
||||
break;
|
||||
case Shared::AccountPassword::jammed:
|
||||
password = crypto.encryptToString(acc->getPassword());
|
||||
#ifdef WITH_SIMPLE_CRYPT2
|
||||
password = SimpleCrypt(passwordHash).encryptToString(acc->getPassword());
|
||||
#else
|
||||
qDebug() << "The password for account" << acc->getName() << "is set to be jammed, but Squawk was compiled without SimpleCrypt support";
|
||||
qDebug("Can not encode password, setting this account to always ask password mode");
|
||||
ap = Shared::AccountPassword::alwaysAsk;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -697,17 +706,24 @@ void Core::Squawk::readSettings() {
|
||||
settings.value("passwordType", static_cast<int>(Shared::AccountPassword::plain)).toInt()
|
||||
);
|
||||
|
||||
QString name = settings.value("name").toString();
|
||||
QString password = settings.value("password", "").toString();
|
||||
if (passwordType == Shared::AccountPassword::jammed) {
|
||||
#ifdef WITH_SIMPLE_CRYPT
|
||||
SimpleCrypt crypto(passwordHash);
|
||||
password = crypto.decryptToString(password);
|
||||
#else
|
||||
qDebug() << "The password for account" << name << "is jammed, but Squawk was compiled without SimpleCrypt support";
|
||||
qDebug("Can not decode password, setting this account to always ask password mode");
|
||||
passwordType = Shared::AccountPassword::alwaysAsk;
|
||||
#endif
|
||||
}
|
||||
|
||||
addAccount(
|
||||
settings.value("login").toString(),
|
||||
settings.value("server").toString(),
|
||||
password,
|
||||
settings.value("name").toString(),
|
||||
name,
|
||||
settings.value("resource").toString(),
|
||||
settings.value("active").toBool(),
|
||||
passwordType
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "shared/global.h"
|
||||
#include "shared/info.h"
|
||||
#include "shared/clientinfo.h"
|
||||
#include "external/simpleCrypt/simplecrypt.h"
|
||||
|
||||
#include <core/components/clientcache.h>
|
||||
#include <core/components/networkaccess.h>
|
||||
|
@ -21,6 +21,13 @@
|
||||
|
||||
#include "enums.h"
|
||||
#include "ui/models/roster.h"
|
||||
|
||||
#ifdef WITH_SIMPLE_CRYPT
|
||||
#define SIMPLE_CRYPT_ENABLED true
|
||||
#else
|
||||
#define SIMPLE_CRYPT_ENABLED false
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OMEMO
|
||||
constexpr bool OMEMO_SUPPORT = true;
|
||||
#else
|
||||
@ -36,12 +43,11 @@ QFont getFont (QFontDatabase::SystemFont type, bool bold = false, bool italic =
|
||||
|
||||
if (factor != 1.0) {
|
||||
float ps = font.pointSizeF();
|
||||
if (ps != -1) {
|
||||
if (ps != -1)
|
||||
font.setPointSizeF(ps * factor);
|
||||
} else {
|
||||
else
|
||||
font.setPointSize(font.pointSize() * factor);
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -148,10 +154,11 @@ Shared::Global::Global():
|
||||
smallFontMetrics(smallFont),
|
||||
headerFontMetrics(headerFont),
|
||||
titleFontMetrics(titleFont),
|
||||
pluginSupport({
|
||||
optionalFeatures({
|
||||
{"KWallet", false},
|
||||
{"openFileManagerWindowJob", false},
|
||||
{"colorSchemeTools", false}
|
||||
{"colorSchemeTools", false},
|
||||
{"simpleCryptJammedPassword", SIMPLE_CRYPT_ENABLED}
|
||||
}),
|
||||
fileCache()
|
||||
{
|
||||
@ -197,8 +204,7 @@ Shared::Global::Global():
|
||||
|
||||
|
||||
static const QSize defaultIconFileInfoHeight(50, 50);
|
||||
Shared::Global::FileInfo Shared::Global::getFileInfo(const QString& path)
|
||||
{
|
||||
Shared::Global::FileInfo Shared::Global::getFileInfo(const QString& path) {
|
||||
std::map<QString, FileInfo>::const_iterator itr = instance->fileCache.find(path);
|
||||
if (itr == instance->fileCache.end()) {
|
||||
QMimeDatabase db;
|
||||
@ -275,17 +281,17 @@ QString Shared::Global::getName(EncryptionProtocol ep) {
|
||||
}
|
||||
|
||||
void Shared::Global::setSupported(const QString& pluginName, bool support) {
|
||||
std::map<QString, bool>::iterator itr = instance->pluginSupport.find(pluginName);
|
||||
if (itr != instance->pluginSupport.end()) {
|
||||
std::map<QString, bool>::iterator itr = instance->optionalFeatures.find(pluginName);
|
||||
if (itr != instance->optionalFeatures.end()) {
|
||||
itr->second = support;
|
||||
}
|
||||
}
|
||||
|
||||
bool Shared::Global::supported(const QString& pluginName) {
|
||||
std::map<QString, bool>::iterator itr = instance->pluginSupport.find(pluginName);
|
||||
if (itr != instance->pluginSupport.end()) {
|
||||
std::map<QString, bool>::iterator itr = instance->optionalFeatures.find(pluginName);
|
||||
if (itr != instance->optionalFeatures.end())
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -325,11 +331,10 @@ void Shared::Global::highlightInFileManager(const QString& path)
|
||||
QString output = proc.readLine().simplified();
|
||||
|
||||
QString folder;
|
||||
if (info.isDir()) {
|
||||
if (info.isDir())
|
||||
folder = info.canonicalFilePath();
|
||||
} else {
|
||||
else
|
||||
folder = info.canonicalPath();
|
||||
}
|
||||
|
||||
if (output.contains(dolphinReg)) {
|
||||
//there is a bug on current (21.04.0) dolphin, it works correct only if you already have dolphin launched
|
||||
@ -389,20 +394,19 @@ void Shared::Global::setTheme(const QString& path) {
|
||||
}
|
||||
|
||||
void Shared::Global::setStyle(const QString& style) {
|
||||
if (style.toLower() == "system") {
|
||||
if (style.toLower() == "system")
|
||||
QApplication::setStyle(getInstance()->defaultSystemStyle);
|
||||
} else {
|
||||
else
|
||||
QApplication::setStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
#define FROM_INT_INPL(Enum) \
|
||||
template<> \
|
||||
Enum Shared::Global::fromInt(int src) \
|
||||
{ \
|
||||
if (src < static_cast<int>(Enum##Lowest) || src > static_cast<int>(Enum##Highest)) { \
|
||||
if (src < static_cast<int>(Enum##Lowest) || src > static_cast<int>(Enum##Highest)) \
|
||||
throw EnumOutOfRange(#Enum); \
|
||||
} \
|
||||
\
|
||||
return static_cast<Enum>(src); \
|
||||
} \
|
||||
template<> \
|
||||
|
@ -135,7 +135,7 @@ namespace Shared {
|
||||
private:
|
||||
static Global* instance;
|
||||
|
||||
std::map<QString, bool> pluginSupport;
|
||||
std::map<QString, bool> optionalFeatures;
|
||||
std::map<QString, FileInfo> fileCache;
|
||||
|
||||
#ifdef WITH_KIO
|
||||
|
@ -26,6 +26,7 @@ Account::Account():
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->passwordType, qOverload<int>(&QComboBox::currentIndexChanged), this, &Account::onComboboxChange);
|
||||
QStandardItemModel *model = static_cast<QStandardItemModel*>(m_ui->passwordType->model());
|
||||
|
||||
for (int i = static_cast<int>(Shared::AccountPasswordLowest); i < static_cast<int>(Shared::AccountPasswordHighest) + 1; ++i) {
|
||||
Shared::AccountPassword ap = static_cast<Shared::AccountPassword>(i);
|
||||
@ -34,18 +35,19 @@ Account::Account():
|
||||
m_ui->passwordType->setCurrentIndex(static_cast<int>(Shared::AccountPassword::plain));
|
||||
|
||||
if (!Shared::Global::supported("KWallet")) {
|
||||
QStandardItemModel *model = static_cast<QStandardItemModel*>(m_ui->passwordType->model());
|
||||
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet));
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
|
||||
}
|
||||
|
||||
if (!Shared::Global::supported("simpleCryptJammedPassword")) {
|
||||
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::jammed));
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
Account::~Account()
|
||||
{
|
||||
}
|
||||
Account::~Account() {}
|
||||
|
||||
QMap<QString, QVariant> Account::value() const
|
||||
{
|
||||
QMap<QString, QVariant> Account::value() const {
|
||||
QMap<QString, QVariant> map;
|
||||
map["login"] = m_ui->login->text();
|
||||
map["password"] = m_ui->password->text();
|
||||
@ -58,13 +60,11 @@ QMap<QString, QVariant> Account::value() const
|
||||
return map;
|
||||
}
|
||||
|
||||
void Account::lockId()
|
||||
{
|
||||
void Account::lockId() {
|
||||
m_ui->name->setReadOnly(true);;
|
||||
}
|
||||
|
||||
void Account::setData(const QMap<QString, QVariant>& data)
|
||||
{
|
||||
void Account::setData(const QMap<QString, QVariant>& data) {
|
||||
m_ui->login->setText(data.value("login").toString());
|
||||
m_ui->password->setText(data.value("password").toString());
|
||||
m_ui->server->setText(data.value("server").toString());
|
||||
@ -73,8 +73,7 @@ void Account::setData(const QMap<QString, QVariant>& data)
|
||||
m_ui->passwordType->setCurrentIndex(data.value("passwordType").toInt());
|
||||
}
|
||||
|
||||
void Account::onComboboxChange(int index)
|
||||
{
|
||||
void Account::onComboboxChange(int index) {
|
||||
QString description = Shared::Global::getDescription(Shared::Global::fromInt<Shared::AccountPassword>(index));
|
||||
m_ui->comment->setText(description);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user