Save bcrypt hash of password (fixes #138)

This commit is contained in:
Jakob Borg
2014-04-19 13:33:51 +02:00
parent 292a50de04
commit 6364c4ff3f
15 changed files with 1319 additions and 140 deletions

View File

@@ -6,6 +6,8 @@ import (
"reflect"
"sort"
"strconv"
"code.google.com/p/go.crypto/bcrypt"
)
type Configuration struct {
@@ -184,6 +186,15 @@ func readConfigXML(rd io.Reader) (Configuration, error) {
convertV1V2(&cfg)
}
if len(cfg.GUI.Password) > 0 && cfg.GUI.Password[0] != '$' {
hash, err := bcrypt.GenerateFromPassword([]byte(cfg.GUI.Password), 0)
if err != nil {
warnln(err)
} else {
cfg.GUI.Password = string(hash)
}
}
return cfg, err
}