fix: keystone user password history check should skip system account

This commit is contained in:
Qiu Jian
2020-03-04 18:34:46 +08:00
parent 1401cfd032
commit 0ca6b0175a
2 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -112,12 +112,12 @@ func validatePasswordComplexity(password string) error {
return nil
}
func (manager *SPasswordManager) validatePassword(localUserId int, password string) error {
func (manager *SPasswordManager) validatePassword(localUserId int, password string, skipHistoryCheck bool) error {
err := validatePasswordComplexity(password)
if err != nil {
return errors.Wrap(err, "validatePasswordComplexity")
}
if o.Options.PasswordUniqueHistoryCheck > 0 {
if !skipHistoryCheck && o.Options.PasswordUniqueHistoryCheck > 0 {
shaPass := shaPassword(password)
histPasses, err := manager.fetchByLocaluserId(localUserId)
if err != nil {
+5 -1
View File
@@ -468,7 +468,11 @@ func (user *SUser) ValidateUpdateData(ctx context.Context, userCred mcclient.Tok
if err != nil {
return nil, errors.Wrap(err, "UserManager.FetchUserExtended")
}
err = PasswordManager.validatePassword(usrExt.LocalId, passwd)
skipHistoryCheck := false
if user.IsSystemAccount.Bool() {
skipHistoryCheck = true
}
err = PasswordManager.validatePassword(usrExt.LocalId, passwd, skipHistoryCheck)
if err != nil {
return nil, httperrors.NewInputParameterError("invalid password: %s", err)
}