mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-11-29 19:59:59 +01:00
Fix tests
This commit is contained in:
parent
6eb25f68ac
commit
5244e0be14
5 changed files with 24 additions and 24 deletions
|
|
@ -41,14 +41,14 @@ func AllowedTier(tier string) bool {
|
|||
}
|
||||
|
||||
// ValidPasswordHash checks if the given password hash is a valid bcrypt hash
|
||||
func ValidPasswordHash(hash string) error {
|
||||
func ValidPasswordHash(hash string, minCost int) 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 {
|
||||
if err != nil { // Check if the hash is valid (length, format, etc.)
|
||||
return err
|
||||
} else if cost < DefaultUserPasswordBcryptCost {
|
||||
} else if cost < minCost {
|
||||
return ErrPasswordHashWeak
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue