add migration of plaintext password to base64

This commit is contained in:
Stephen Birarda 2016-04-05 11:18:57 -07:00
parent 7c6c75c484
commit fd2ee8ce4e
2 changed files with 27 additions and 3 deletions

View file

@ -1,5 +1,5 @@
{
"version": 1.1,
"version": 1.2,
"settings": [
{
"name": "metaverse",
@ -249,7 +249,7 @@
"label": "X end",
"can_set": true,
"placeholder": "16384.0"
},
},
{
"name": "y_min",
"label": "Y start",

View file

@ -129,7 +129,9 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
// reload the master and user config so that the merged config is right
_configMap.loadMasterAndUserConfig(argumentList);
}
} else if (oldVersion < 1.1) {
}
if (oldVersion < 1.1) {
static const QString ENTITY_SERVER_SETTINGS_KEY = "entity_server_settings";
static const QString ENTITY_FILE_NAME_KEY = "persistFilename";
static const QString ENTITY_FILE_PATH_KEYPATH = ENTITY_SERVER_SETTINGS_KEY + ".persistFilePath";
@ -165,6 +167,28 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
}
}
if (oldVersion < 1.2) {
// This was prior to the base64 encoding of password for HTTP Basic Authentication.
// If we have a password in the previous settings file, make it base 64
static const QString BASIC_AUTH_PASSWORD_KEY_PATH { "security.http_password" };
QVariant* passwordVariant = valueForKeyPath(_configMap.getUserConfig(), BASIC_AUTH_PASSWORD_KEY_PATH);
if (passwordVariant && passwordVariant->canConvert(QMetaType::QString)) {
QString plaintextPassword = passwordVariant->toString();
qDebug() << "Migrating plaintext password to base64 password in domain-server settings.";
*passwordVariant = plaintextPassword.toUtf8().toBase64();
// write the new settings to file
persistToFile();
// reload the master and user config so the merged config is correct
_configMap.loadMasterAndUserConfig(argumentList);
}
}
}
// write the current description version to our settings