Credentials: Namespace windows cred keys #6125

The application name is prepended to the key. QtKeychain doesn't
do that automatically on the platform.
This commit is contained in:
Christian Kamm 2017-10-26 13:36:21 +02:00 committed by ckamm
parent 64a84fda38
commit 6ac44f05cd

View file

@ -14,6 +14,7 @@
#include <QLoggingCategory>
#include <QString>
#include <QCoreApplication>
#include "common/asserts.h"
#include "creds/abstractcredentials.h"
@ -53,6 +54,15 @@ QString AbstractCredentials::keychainKey(const QString &url, const QString &user
QString key = user + QLatin1Char(':') + u;
if (!accountId.isEmpty()) {
key += QLatin1Char(':') + accountId;
#ifdef Q_OS_WIN
// On Windows the credential keys aren't namespaced properly
// by qtkeychain. To work around that we manually add namespacing
// to the generated keys. See #6125.
// It's safe to do that since the key format is changing for 2.4
// anyway to include the account ids. That means old keys can be
// migrated to new namespaced keys on windows for 2.4.
key.prepend(QCoreApplication::applicationName() + "_");
#endif
}
return key;
}