refactor the password hashing / password autoupgrade system

This commit is contained in:
Shivaram Lingamneni
2018-08-05 22:51:39 -04:00
parent 6260869068
commit dfb0a57040
18 changed files with 277 additions and 380 deletions
+3 -3
View File
@@ -17,8 +17,8 @@ import (
"github.com/oragono/oragono/irc"
"github.com/oragono/oragono/irc/logger"
"github.com/oragono/oragono/irc/mkcerts"
"github.com/oragono/oragono/irc/passwd"
stackimpact "github.com/stackimpact/stackimpact-go"
"golang.org/x/crypto/bcrypt"
"golang.org/x/crypto/ssh/terminal"
)
@@ -73,11 +73,11 @@ Options:
if confirm != password {
log.Fatal("passwords do not match")
}
encoded, err := passwd.GenerateEncodedPassword(password)
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.MinCost)
if err != nil {
log.Fatal("encoding error:", err.Error())
}
fmt.Println(encoded)
fmt.Println(string(hash))
} else if arguments["initdb"].(bool) {
irc.InitDB(config.Datastore.Path)
if !arguments["--quiet"].(bool) {