Merge pull request #5338 from swordqiu/automated-cherry-pick-of-#5336-upstream-release-3.1

Automated cherry pick of #5336: fix: keystone user password history check should skip system account
This commit is contained in:
Zexi Li
2020-03-04 19:16:27 +08:00
committed by GitHub
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
@@ -436,7 +436,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)
}