lib/config: Accept pre-hashed password (fixes #9123) (#9124)

This commit is contained in:
Jakob Borg
2023-09-24 19:23:49 +02:00
committed by GitHub
parent 19bbf4f6bf
commit 6ed9c0c34c
5 changed files with 32 additions and 9 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ var guiCfg config.GUIConfiguration
func init() {
guiCfg.User = "user"
guiCfg.HashAndSetPassword("pass")
guiCfg.SetPassword("pass")
}
func TestStaticAuthOK(t *testing.T) {
+2 -2
View File
@@ -319,7 +319,7 @@ func (c *configMuxBuilder) adjustConfig(w http.ResponseWriter, r *http.Request)
var status int
waiter, err := c.cfg.Modify(func(cfg *config.Configuration) {
if to.GUI.Password != cfg.GUI.Password {
if err := to.GUI.HashAndSetPassword(to.GUI.Password); err != nil {
if err := to.GUI.SetPassword(to.GUI.Password); err != nil {
l.Warnln("hashing password:", err)
errMsg = err.Error()
status = http.StatusInternalServerError
@@ -401,7 +401,7 @@ func (c *configMuxBuilder) adjustGUI(w http.ResponseWriter, r *http.Request, gui
var status int
waiter, err := c.cfg.Modify(func(cfg *config.Configuration) {
if gui.Password != oldPassword {
if err := gui.HashAndSetPassword(gui.Password); err != nil {
if err := gui.SetPassword(gui.Password); err != nil {
l.Warnln("hashing password:", err)
errMsg = err.Error()
status = http.StatusInternalServerError