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:
parent
efe7c3fa70
commit
6eb25f68ac
4 changed files with 10 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue