mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Enable insecure fallback for secret storage
This commit is contained in:
parent
ad57a336dc
commit
71290e208d
3 changed files with 13 additions and 4 deletions
|
@ -722,8 +722,8 @@ Cache::storeSecret(const std::string name, const std::string secret)
|
||||||
auto job = new QKeychain::WritePasswordJob(QCoreApplication::applicationName());
|
auto job = new QKeychain::WritePasswordJob(QCoreApplication::applicationName());
|
||||||
job->setAutoDelete(true);
|
job->setAutoDelete(true);
|
||||||
job->setInsecureFallback(true);
|
job->setInsecureFallback(true);
|
||||||
|
job->setSettings(UserSettings::instance()->qsettings());
|
||||||
|
|
||||||
// job->setSettings(new QSettings(job));
|
|
||||||
job->setKey(
|
job->setKey(
|
||||||
"matrix." +
|
"matrix." +
|
||||||
QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)
|
QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)
|
||||||
|
@ -731,6 +731,7 @@ Cache::storeSecret(const std::string name, const std::string secret)
|
||||||
"." + QString::fromStdString(name));
|
"." + QString::fromStdString(name));
|
||||||
|
|
||||||
job->setTextData(QString::fromStdString(secret));
|
job->setTextData(QString::fromStdString(secret));
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
job,
|
job,
|
||||||
&QKeychain::WritePasswordJob::finished,
|
&QKeychain::WritePasswordJob::finished,
|
||||||
|
@ -758,11 +759,14 @@ Cache::deleteSecret(const std::string name)
|
||||||
QKeychain::DeletePasswordJob job(QCoreApplication::applicationName());
|
QKeychain::DeletePasswordJob job(QCoreApplication::applicationName());
|
||||||
job.setAutoDelete(false);
|
job.setAutoDelete(false);
|
||||||
job.setInsecureFallback(true);
|
job.setInsecureFallback(true);
|
||||||
|
job.setSettings(UserSettings::instance()->qsettings());
|
||||||
|
|
||||||
job.setKey(
|
job.setKey(
|
||||||
"matrix." +
|
"matrix." +
|
||||||
QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)
|
QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)
|
||||||
.toBase64()) +
|
.toBase64()) +
|
||||||
"." + QString::fromStdString(name));
|
"." + QString::fromStdString(name));
|
||||||
|
|
||||||
// FIXME(Nico): Nested event loops are dangerous. Some other slots may resume in the mean
|
// FIXME(Nico): Nested event loops are dangerous. Some other slots may resume in the mean
|
||||||
// time!
|
// time!
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
|
@ -780,11 +784,14 @@ Cache::secret(const std::string name)
|
||||||
QKeychain::ReadPasswordJob job(QCoreApplication::applicationName());
|
QKeychain::ReadPasswordJob job(QCoreApplication::applicationName());
|
||||||
job.setAutoDelete(false);
|
job.setAutoDelete(false);
|
||||||
job.setInsecureFallback(true);
|
job.setInsecureFallback(true);
|
||||||
|
job.setSettings(UserSettings::instance()->qsettings());
|
||||||
|
|
||||||
job.setKey(
|
job.setKey(
|
||||||
"matrix." +
|
"matrix." +
|
||||||
QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)
|
QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)
|
||||||
.toBase64()) +
|
.toBase64()) +
|
||||||
"." + QString::fromStdString(name));
|
"." + QString::fromStdString(name));
|
||||||
|
|
||||||
// FIXME(Nico): Nested event loops are dangerous. Some other slots may resume in the mean
|
// FIXME(Nico): Nested event loops are dangerous. Some other slots may resume in the mean
|
||||||
// time!
|
// time!
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QScroller>
|
#include <QScroller>
|
||||||
#include <QSettings>
|
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -63,7 +62,6 @@ UserSettings::initialize(std::optional<QString> profile)
|
||||||
void
|
void
|
||||||
UserSettings::load(std::optional<QString> profile)
|
UserSettings::load(std::optional<QString> profile)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
tray_ = settings.value("user/window/tray", false).toBool();
|
tray_ = settings.value("user/window/tray", false).toBool();
|
||||||
startInTray_ = settings.value("user/window/start_in_tray", false).toBool();
|
startInTray_ = settings.value("user/window/start_in_tray", false).toBool();
|
||||||
|
|
||||||
|
@ -601,7 +599,6 @@ UserSettings::applyTheme()
|
||||||
void
|
void
|
||||||
UserSettings::save()
|
UserSettings::save()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("user");
|
settings.beginGroup("user");
|
||||||
|
|
||||||
settings.beginGroup("window");
|
settings.beginGroup("window");
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QSettings>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
@ -107,6 +108,8 @@ public:
|
||||||
static QSharedPointer<UserSettings> instance();
|
static QSharedPointer<UserSettings> instance();
|
||||||
static void initialize(std::optional<QString> profile);
|
static void initialize(std::optional<QString> profile);
|
||||||
|
|
||||||
|
QSettings *qsettings() { return &settings; }
|
||||||
|
|
||||||
enum class Presence
|
enum class Presence
|
||||||
{
|
{
|
||||||
AutomaticPresence,
|
AutomaticPresence,
|
||||||
|
@ -316,6 +319,8 @@ private:
|
||||||
QString homeserver_;
|
QString homeserver_;
|
||||||
QStringList hiddenTags_;
|
QStringList hiddenTags_;
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
static QSharedPointer<UserSettings> instance_;
|
static QSharedPointer<UserSettings> instance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue