convert htpasswd regexes to globals

This commit is contained in:
Michael Eischer 2021-03-27 17:39:16 +01:00 committed by Leo R. Lundgren
parent 5a6ed2ffdf
commit 98f0aaca1c

View file

@ -211,6 +211,9 @@ func (h *HtpasswdFile) ReloadCheck() error {
return nil
}
var shaRe = regexp.MustCompile(`^{SHA}`)
var bcrRe = regexp.MustCompile(`^\$2b\$|^\$2a\$|^\$2y\$`)
// Validate returns true if password matches the stored password for user. If no password for user is stored, or the
// password is wrong, false is returned.
func (h *HtpasswdFile) Validate(user string, password string) bool {
@ -245,9 +248,6 @@ func (h *HtpasswdFile) Validate(user string, password string) bool {
return true
}
var shaRe = regexp.MustCompile(`^{SHA}`)
var bcrRe = regexp.MustCompile(`^\$2b\$|^\$2a\$|^\$2y\$`)
isValid := false
switch {