Authentication errors: try to avoid user enumeration

Fixes #395
This commit is contained in:
Nicola Murino
2021-04-26 19:48:21 +02:00
parent 7778716fa7
commit 1275328fdf
7 changed files with 59 additions and 17 deletions

View File

@@ -125,7 +125,7 @@ func (a *Admin) validate() error {
func (a *Admin) CheckPassword(password string) (bool, error) {
if strings.HasPrefix(a.Password, bcryptPwdPrefix) {
if err := bcrypt.CompareHashAndPassword([]byte(a.Password), []byte(password)); err != nil {
return false, err
return false, ErrInvalidCredentials
}
return true, nil
}