PLT-4005 Generates default Salts if empty in the config file (#3950)

Этот коммит содержится в:
enahum
2016-09-06 09:21:18 -03:00
коммит произвёл Joram Wilander
родитель 4bd5935bd8
Коммит 886ab34443
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@@ -52,7 +52,7 @@
"MaxIdleConns": 10, "MaxIdleConns": 10,
"MaxOpenConns": 10, "MaxOpenConns": 10,
"Trace": false, "Trace": false,
"AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QVg" "AtRestEncryptKey": ""
}, },
"LogSettings": { "LogSettings": {
"EnableConsole": true, "EnableConsole": true,
@@ -75,7 +75,7 @@
"DriverName": "local", "DriverName": "local",
"Directory": "./data/", "Directory": "./data/",
"EnablePublicLink": false, "EnablePublicLink": false,
"PublicLinkSalt": "A705AklYF8MFDOfcwh3I488G8vtLlVip", "PublicLinkSalt": "",
"ThumbnailWidth": 120, "ThumbnailWidth": 120,
"ThumbnailHeight": 100, "ThumbnailHeight": 100,
"PreviewWidth": 1024, "PreviewWidth": 1024,
@@ -106,8 +106,8 @@
"SMTPServer": "", "SMTPServer": "",
"SMTPPort": "", "SMTPPort": "",
"ConnectionSecurity": "", "ConnectionSecurity": "",
"InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS", "InviteSalt": "",
"PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL", "PasswordResetSalt": "",
"SendPushNotifications": false, "SendPushNotifications": false,
"PushNotificationServer": "", "PushNotificationServer": "",
"PushNotificationContents": "generic", "PushNotificationContents": "generic",

Просмотреть файл

@@ -165,12 +165,21 @@ func LoadConfig(fileName string) {
CfgFileName = fileName CfgFileName = fileName
} }
needSave := len(config.SqlSettings.AtRestEncryptKey) == 0 || len(*config.FileSettings.PublicLinkSalt) == 0 ||
len(config.EmailSettings.InviteSalt) == 0 || len(config.EmailSettings.PasswordResetSalt) == 0
config.SetDefaults() config.SetDefaults()
if err := config.IsValid(); err != nil { if err := config.IsValid(); err != nil {
panic(T(err.Id)) panic(T(err.Id))
} }
if needSave {
if err := SaveConfig(fileName, &config); err != nil {
l4g.Warn(T(err.Id))
}
}
if err := ValidateLdapFilter(&config); err != nil { if err := ValidateLdapFilter(&config); err != nil {
panic(T(err.Id)) panic(T(err.Id))
} }