From 886ab34443b25fa8f4d81e954dd8e4bfe6f99511 Mon Sep 17 00:00:00 2001 From: enahum Date: Tue, 6 Sep 2016 09:21:18 -0300 Subject: [PATCH] PLT-4005 Generates default Salts if empty in the config file (#3950) --- config/config.json | 8 ++++---- utils/config.go | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config/config.json b/config/config.json index 56ced04b56..9756a356a0 100644 --- a/config/config.json +++ b/config/config.json @@ -52,7 +52,7 @@ "MaxIdleConns": 10, "MaxOpenConns": 10, "Trace": false, - "AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QVg" + "AtRestEncryptKey": "" }, "LogSettings": { "EnableConsole": true, @@ -75,7 +75,7 @@ "DriverName": "local", "Directory": "./data/", "EnablePublicLink": false, - "PublicLinkSalt": "A705AklYF8MFDOfcwh3I488G8vtLlVip", + "PublicLinkSalt": "", "ThumbnailWidth": 120, "ThumbnailHeight": 100, "PreviewWidth": 1024, @@ -106,8 +106,8 @@ "SMTPServer": "", "SMTPPort": "", "ConnectionSecurity": "", - "InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS", - "PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL", + "InviteSalt": "", + "PasswordResetSalt": "", "SendPushNotifications": false, "PushNotificationServer": "", "PushNotificationContents": "generic", diff --git a/utils/config.go b/utils/config.go index a42b608b23..f4186d352c 100644 --- a/utils/config.go +++ b/utils/config.go @@ -165,12 +165,21 @@ func LoadConfig(fileName string) { 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() if err := config.IsValid(); err != nil { panic(T(err.Id)) } + if needSave { + if err := SaveConfig(fileName, &config); err != nil { + l4g.Warn(T(err.Id)) + } + } + if err := ValidateLdapFilter(&config); err != nil { panic(T(err.Id)) }