zhongrj
2023-04-25 79219739a02c92e9e9d3b89071f6a699cd0cf1c8
skjcmanager/skjcmanager-auth/src/main/java/cn/gistack/auth/config/MyAuthenticationProvider.java
@@ -16,6 +16,7 @@
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.exceptions.UserDeniedAuthorizationException;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
@@ -70,12 +71,11 @@
            String tenantId = StringUtils.isBlank(headerTenant) ? paramTenant : headerTenant;
            String detailsPassword = userDetails.getPassword().substring(7);
            if (!detailsPassword.equals(DigestUtil.hex(password))) {
               int count = getFailCount(tenantId, userDetails.getUsername());
               // 用户存在但密码错误,超过次数则锁定账号
               if (grantType != null && !grantType.equals(TokenUtil.REFRESH_TOKEN_KEY)) {
                  setFailCount(tenantId, userDetails.getUsername(), count);
                  throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
                  throw new UserDeniedAuthorizationException(TokenUtil.USER_NOT_FOUND);
               }
               this.logger.debug("Failed to authenticate since password does not match stored value");
               throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));