1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-11-29 03:40:32 +01:00

Update password hash docs, add more validation on password hash

This commit is contained in:
binwiederhier 2025-08-09 07:34:19 -04:00
parent efe7c3fa70
commit 6eb25f68ac
4 changed files with 10 additions and 3 deletions

View file

@ -45,6 +45,12 @@ func ValidPasswordHash(hash string) error {
if !strings.HasPrefix(hash, "$2a$") && !strings.HasPrefix(hash, "$2b$") && !strings.HasPrefix(hash, "$2y$") {
return ErrPasswordHashInvalid
}
cost, err := bcrypt.Cost([]byte(hash))
if err != nil {
return err
} else if cost < DefaultUserPasswordBcryptCost {
return ErrPasswordHashWeak
}
return nil
}