Skip to content

Commit ccf58ff

Browse files
author
ffffwh
authored
Merge pull request #768 from actiontech/white_list
Optimize user permissions
2 parents 929cdb2 + ac86858 commit ccf58ff

File tree

17 files changed

+2107
-407
lines changed

17 files changed

+2107
-407
lines changed

drivers/api/docs/docs.go

Lines changed: 642 additions & 105 deletions
Large diffs are not rendered by default.

drivers/api/docs/swagger.json

Lines changed: 642 additions & 105 deletions
Large diffs are not rendered by default.

drivers/api/docs/swagger.yaml

Lines changed: 388 additions & 55 deletions
Large diffs are not rendered by default.

drivers/api/handler/v2/auth.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ func (b *BlackList) blackListExist(key string) (int, bool) {
6060
}
6161

6262
// validate current user in blacklist and update blacklist
63-
func ValidatePassword(user, operation, currentPwd, verifiedPwd string) error {
64-
if leftMinute, exist := BL.blackListExist(fmt.Sprintf("%s:%s", user, operation)); exist {
65-
return fmt.Errorf("the password cannot be changed temporarily, please try again after %v minute", leftMinute)
66-
}
63+
func ValidatePassword(blackListKey, currentPwd, verifiedPwd string) error {
6764
realCurrentPwd, err := handler.DecryptPasswordSupportNoRsaKey(currentPwd, g.RsaPrivateKey)
6865
if err != nil {
6966
return fmt.Errorf("decrypt current password err")
@@ -73,7 +70,7 @@ func ValidatePassword(user, operation, currentPwd, verifiedPwd string) error {
7370
return fmt.Errorf("decrypt verified password err")
7471
}
7572
if realCurrentPwd != realVerifiedPwd {
76-
BL.setBlackList(fmt.Sprintf("%s:%s", user, operation), time.Minute*30)
73+
BL.setBlackList(blackListKey, time.Minute*30)
7774
return fmt.Errorf("user or password is wrong")
7875
}
7976
return nil

0 commit comments

Comments
 (0)