This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 64a98ea restrict the length of password (#819)
64a98ea is described below
commit 64a98ead04abf3f20c703556ecb2558a1271a2d9
Author: hityc2019 <[email protected]>
AuthorDate: Fri Jan 8 14:59:43 2021 +0800
restrict the length of password (#819)
---
docs/user-guides/rbac.md | 2 +-
pkg/validate/matcher.go | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/docs/user-guides/rbac.md b/docs/user-guides/rbac.md
index 48821cc..a38fc20 100644
--- a/docs/user-guides/rbac.md
+++ b/docs/user-guides/rbac.md
@@ -21,7 +21,7 @@ auth_plugin = buildin # must set to buildin
```
3.root account
-before you start server, you need to set env to set your root account
password. Please note that password must conform to the [following set of
rules](https://github.com/apache/servicecomb-service-center/blob/63722fadd511c26285e787eb2b4be516eab10b94/pkg/validate/matcher.go#L25):
have more than 8 characters, have at least one upper alpha, have at least one
lower alpha, have at least one digit and have at lease one special character.
+before you start server, you need to set env to set your root account
password. Please note that password must conform to the [following set of
rules](https://github.com/apache/servicecomb-service-center/blob/63722fadd511c26285e787eb2b4be516eab10b94/pkg/validate/matcher.go#L25):
have at least 8 characters, have at most 32 characters, have at least one
upper alpha, have at least one lower alpha, have at least one digit and have at
lease one special character.
```sh
export SC_INIT_ROOT_PASSWORD='P4$$word'
diff --git a/pkg/validate/matcher.go b/pkg/validate/matcher.go
index 333fd8c..85417d4 100644
--- a/pkg/validate/matcher.go
+++ b/pkg/validate/matcher.go
@@ -24,14 +24,14 @@ type PasswordChecker struct {
func (p *PasswordChecker) MatchString(s string) bool {
var (
- hasMinLen = false
- hasUpper = false
- hasLower = false
- hasNumber = false
- hasSpecial = false
+ hasValidLen = false
+ hasUpper = false
+ hasLower = false
+ hasNumber = false
+ hasSpecial = false
)
- if len(s) >= 8 {
- hasMinLen = true
+ if len(s) >= 8 && len(s) <= 32 {
+ hasValidLen = true
}
for _, char := range s {
switch {
@@ -45,7 +45,7 @@ func (p *PasswordChecker) MatchString(s string) bool {
hasSpecial = true
}
}
- return hasMinLen && hasUpper && hasLower && hasNumber && hasSpecial
+ return hasValidLen && hasUpper && hasLower && hasNumber && hasSpecial
}
func (p *PasswordChecker) String() string {
return "password"