commit 2a9345852c39be86dab6c221dd7d95363ab8dc96 parent 5dee01ad21ce8282734a3b7dbb1adb62c4be9570 Author: Martin Schanzenbach <mschanzenbach@posteo.de> Date: Tue, 19 Apr 2022 17:58:01 +0200 Preferably get salt from ENV Diffstat:
| M | taldir.go | | | 9 | ++++++--- |
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/taldir.go b/taldir.go @@ -104,11 +104,14 @@ func returnSingleEntry(w http.ResponseWriter, r *http.Request){ // Hashes an identity key (e.g. sha256(<email address>)) with a salt for // Lookup and storage. func hashIdentityKey(idkey string) string { - fmt.Println("Using salt " + cfg.Section("taldir").Key("salt").MustString("ChangeMe")) - salt := make([]byte, len(cfg.Section("taldir").Key("salt").MustString("ChangeMe"))) + salt := os.Getenv("TALDIR_SALT") + if "" == salt { + salt = cfg.Section("taldir").Key("salt").MustString("ChangeMe") + } + fmt.Println("Using salt " + salt) h := sha256.New() h.Write([]byte(idkey)) - h.Write(salt) + h.Write([]byte(salt)) return base32.StdEncoding.EncodeToString(h.Sum(nil)) }