You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by "humingcheng (via GitHub)" <gi...@apache.org> on 2025/09/02 06:48:46 UTC
Re: [PR] support custom validator,add weak password validator [servicecomb-service-center]
humingcheng commented on code in PR #1519:
URL: https://github.com/apache/servicecomb-service-center/pull/1519#discussion_r2315077680
##########
server/service/validator/validator.go:
##########
@@ -32,3 +46,32 @@ func baseCheck(v interface{}) error {
}
return nil
}
+
+func customValidate(v interface{}, targetValidators ...string) error {
Review Comment:
这个方法的逻辑:传入多个validator,找到第一个实际存在的validator,并返回该validator的校验结果?把这个逻辑用注释说明一下。
##########
server/service/validator/rbac_validator.go:
##########
@@ -47,13 +57,68 @@ func init() {
changePWDValidator.AddRule("Name", &validate.Rule{Regexp: accountNameRegex})
accountLoginValidator.AddRule("TokenExpirationTime", &validate.Rule{Regexp: &validate.TokenExpirationTimeChecker{}})
+
+ initCustomValidator()
+}
+
+func initPasswordCustomValidator() {
+ weakPasswordPath := filepath.Join(util.GetAppRoot(), "conf", "weakpassord.txt")
+ weakPasswords, err := loadWeakPasswords(weakPasswordPath)
+ if err != nil {
+ log.Error("failed to load weak password", err)
+ return
Review Comment:
弱密码字典初始化失败,整个进程要报错退出。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org