diff --git a/api/internal/passwordutils/strengthCheck.go b/api/internal/passwordutils/strengthCheck.go index 99d5ca473..f6de54d9c 100644 --- a/api/internal/passwordutils/strengthCheck.go +++ b/api/internal/passwordutils/strengthCheck.go @@ -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) } diff --git a/api/internal/passwordutils/strengthCheck_test.go b/api/internal/passwordutils/strengthCheck_test.go index 1ee45461a..a84871054 100644 --- a/api/internal/passwordutils/strengthCheck_test.go +++ b/api/internal/passwordutils/strengthCheck_test.go @@ -13,9 +13,9 @@ func TestStrengthCheck(t *testing.T) { }{ {"Empty password", args{""}, false}, {"Short password", args{"portainer"}, false}, - {"Short password", args{"portaienr!@#"}, false}, + {"Short password", args{"portaienr!@#"}, true}, {"Week password", args{"12345678!@#"}, false}, - {"Week password", args{"portaienr123"}, false}, + {"Week password", args{"portaienr123"}, true}, {"Good password", args{"Portainer123"}, true}, {"Good password", args{"Portainer___"}, true}, {"Good password", args{"^portainer12"}, true}, diff --git a/app/portainer/components/PasswordCheckHint.tsx b/app/portainer/components/PasswordCheckHint.tsx index ba6ed8854..463aba0c6 100644 --- a/app/portainer/components/PasswordCheckHint.tsx +++ b/app/portainer/components/PasswordCheckHint.tsx @@ -2,17 +2,6 @@ import { react2angular } from '@/react-tools/react2angular'; import { MinPasswordLen } from '../helpers/password'; -function PasswordCombination() { - return ( -
- The password must be at least {MinPasswordLen} characters long, - including a combination of one character of three of the below: + The password must be at least {MinPasswordLen} characters long.
- -- The password must be at least {{ MinPasswordLen }} characters long, including a combination of one character of three of the below: + The password must be at least {{ MinPasswordLen }} characters long.
-