【8.0】【auth】最大错误登录次数增加变量控制

pull/57/head
fengshuonan 2023-10-03 20:30:32 +08:00
parent 685cb81dbc
commit c227eb1524
2 changed files with 14 additions and 10 deletions

View File

@ -1,22 +1,26 @@
package cn.stylefeng.roses.kernel.auth.api.expander; package cn.stylefeng.roses.kernel.auth.api.expander;
import cn.stylefeng.roses.kernel.auth.api.constants.LoginCacheConstants;
import cn.stylefeng.roses.kernel.config.api.context.ConfigContext; import cn.stylefeng.roses.kernel.config.api.context.ConfigContext;
/** /**
* *
* *
* @author xixiaowei * @author fengshuonan
* @since 2022/1/24 15:47 * @since 2023/10/3 20:24
*/ */
public class LoginConfigExpander { public class LoginConfigExpander {
/** /**
* *
* <p>
*
* *
* @author xixiaowei * @author fengshuonan
* @since 2022/1/24 15:48 * @since 2023/10/3 20:25
*/ */
public static boolean getAccountErrorDetectionFlag() { public static Integer getMaxErrorLoginCount() {
return ConfigContext.me().getSysConfigValueWithDefault("ACCOUNT_ERROR_DETECTION", Boolean.class, false); return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_MAX_ERROR_LOGIN_COUNT", Integer.class, LoginCacheConstants.MAX_ERROR_LOGIN_COUNT);
} }
} }

View File

@ -10,12 +10,12 @@ import cn.stylefeng.roses.kernel.auth.api.SsoServerApi;
import cn.stylefeng.roses.kernel.auth.api.TempSecretApi; import cn.stylefeng.roses.kernel.auth.api.TempSecretApi;
import cn.stylefeng.roses.kernel.auth.api.TenantCodeGetApi; import cn.stylefeng.roses.kernel.auth.api.TenantCodeGetApi;
import cn.stylefeng.roses.kernel.auth.api.constants.AuthConstants; import cn.stylefeng.roses.kernel.auth.api.constants.AuthConstants;
import cn.stylefeng.roses.kernel.auth.api.constants.LoginCacheConstants;
import cn.stylefeng.roses.kernel.auth.api.context.AuthJwtContext; import cn.stylefeng.roses.kernel.auth.api.context.AuthJwtContext;
import cn.stylefeng.roses.kernel.auth.api.enums.SsoClientTypeEnum; import cn.stylefeng.roses.kernel.auth.api.enums.SsoClientTypeEnum;
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException; import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum; import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum;
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander; import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
import cn.stylefeng.roses.kernel.auth.api.expander.LoginConfigExpander;
import cn.stylefeng.roses.kernel.auth.api.password.PasswordStoredEncryptApi; import cn.stylefeng.roses.kernel.auth.api.password.PasswordStoredEncryptApi;
import cn.stylefeng.roses.kernel.auth.api.password.PasswordTransferEncryptApi; import cn.stylefeng.roses.kernel.auth.api.password.PasswordTransferEncryptApi;
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest; import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest;
@ -238,7 +238,7 @@ public class LoginService {
*/ */
private Integer validatePasswordRetryTimes(LoginRequest loginRequest) { private Integer validatePasswordRetryTimes(LoginRequest loginRequest) {
Integer loginErrorCount = loginErrorCountCacheApi.get(loginRequest.getAccount()); Integer loginErrorCount = loginErrorCountCacheApi.get(loginRequest.getAccount());
if (loginErrorCount != null && loginErrorCount >= LoginCacheConstants.MAX_ERROR_LOGIN_COUNT) { if (loginErrorCount != null && loginErrorCount >= LoginConfigExpander.getMaxErrorLoginCount()) {
throw new AuthException(AuthExceptionEnum.LOGIN_LOCKED); throw new AuthException(AuthExceptionEnum.LOGIN_LOCKED);
} }
return loginErrorCount; return loginErrorCount;