1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

fix(pwd) EE-3161 ease the minimum password restrictions to 12 characters (#6921)

* fix(pwd): EE-3161 ease the minimum password restrictions to 12 characters
This commit is contained in:
cong meng 2022-05-12 13:17:01 +12:00 committed by GitHub
parent d9d1d6bfaa
commit 16f8b737f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 65 deletions

View file

@ -1,33 +1,11 @@
package passwordutils
import (
"regexp"
)
const MinPasswordLen = 12
func lengthCheck(password string) bool {
return len(password) >= MinPasswordLen
}
func comboCheck(password string) bool {
count := 0
regexps := [4]*regexp.Regexp{
regexp.MustCompile(`[a-z]`),
regexp.MustCompile(`[A-Z]`),
regexp.MustCompile(`[0-9]`),
regexp.MustCompile(`[\W_]`),
}
for _, re := range regexps {
if re.FindString(password) != "" {
count += 1
}
}
return count >= 3
}
func StrengthCheck(password string) bool {
return lengthCheck(password) && comboCheck(password)
return lengthCheck(password)
}