lib/http: Factor password hash salt into options with default

This commit is contained in:
Nolan Woods 2021-10-12 10:32:46 -07:00 committed by Nick Craig-Wood
parent b1cb41f8da
commit 023e32de05
2 changed files with 10 additions and 4 deletions

View file

@ -85,9 +85,9 @@ func HtPasswdAuth(path, realm string) httplib.Middleware {
}
// SingleAuth instantiates middleware that authenticates for a single user
func SingleAuth(user, pass, realm string) httplib.Middleware {
func SingleAuth(user, pass, realm, salt string) httplib.Middleware {
fs.Infof(nil, "Using --user %s --pass XXXX as authenticated user", user)
pass = string(auth.MD5Crypt([]byte(pass), []byte("dlPL2MqE"), []byte("$1$")))
pass = string(auth.MD5Crypt([]byte(pass), []byte(salt), []byte("$1$")))
secretProvider := func(u, r string) string {
if user == u {
return pass