diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-18 11:40:41 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-18 11:40:45 +0200 |
commit | a7e7f7fdd2a9d38921476d57f305c9cd4459a556 (patch) | |
tree | d9ad3bdc3e275004a54f508025f0d52227ab18cb /common/synchronizer.cpp | |
parent | ea2e02ad656640c17d520b5a22c168c3c1faef56 (diff) | |
download | sink-a7e7f7fdd2a9d38921476d57f305c9cd4459a556.tar.gz sink-a7e7f7fdd2a9d38921476d57f305c9cd4459a556.zip |
Avoid storing the password in the configuration
The password (or any other secret), is now cached in the client process
(in-memory only), and delivered to the resource via command.
The resource avoids doing any operations against the source until the
secret is available.
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r-- | common/synchronizer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 959cf48..4a0ac46 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp | |||
@@ -49,6 +49,20 @@ Synchronizer::~Synchronizer() | |||
49 | 49 | ||
50 | } | 50 | } |
51 | 51 | ||
52 | void Synchronizer::setSecret(const QString &s) | ||
53 | { | ||
54 | mSecret = s; | ||
55 | |||
56 | if (!mSyncRequestQueue.isEmpty()) { | ||
57 | processSyncQueue().exec(); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | QString Synchronizer::secret() const | ||
62 | { | ||
63 | return mSecret; | ||
64 | } | ||
65 | |||
52 | void Synchronizer::setup(const std::function<void(int commandId, const QByteArray &data)> &enqueueCommandCallback, MessageQueue &mq) | 66 | void Synchronizer::setup(const std::function<void(int commandId, const QByteArray &data)> &enqueueCommandCallback, MessageQueue &mq) |
53 | { | 67 | { |
54 | mEnqueue = enqueueCommandCallback; | 68 | mEnqueue = enqueueCommandCallback; |
@@ -474,6 +488,10 @@ void Synchronizer::setBusy(bool busy, const QString &reason, const QByteArray re | |||
474 | 488 | ||
475 | KAsync::Job<void> Synchronizer::processSyncQueue() | 489 | KAsync::Job<void> Synchronizer::processSyncQueue() |
476 | { | 490 | { |
491 | if (secret().isEmpty()) { | ||
492 | SinkLogCtx(mLogCtx) << "Secret not available but required."; | ||
493 | return KAsync::null<void>(); | ||
494 | } | ||
477 | if (mSyncRequestQueue.isEmpty()) { | 495 | if (mSyncRequestQueue.isEmpty()) { |
478 | SinkLogCtx(mLogCtx) << "All requests processed."; | 496 | SinkLogCtx(mLogCtx) << "All requests processed."; |
479 | return KAsync::null<void>(); | 497 | return KAsync::null<void>(); |