diff --git a/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java b/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java index 87de3f917..048b94b6c 100644 --- a/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java +++ b/kernel-d-auth/auth-api/src/main/java/cn/stylefeng/roses/kernel/auth/api/expander/LoginConfigExpander.java @@ -1,22 +1,26 @@ 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; /** - * 登录相关配置快速获取 + * 登录相关的配置 * - * @author xixiaowei - * @since 2022/1/24 15:47 + * @author fengshuonan + * @since 2023/10/3 20:24 */ public class LoginConfigExpander { /** - * 获取帐号错误次数校验开关 + * 登录账号密码登录最大的错误次数 + *

+ * 超过此次数则冻结账号 * - * @author xixiaowei - * @since 2022/1/24 15:48 + * @author fengshuonan + * @since 2023/10/3 20:25 */ - public static boolean getAccountErrorDetectionFlag() { - return ConfigContext.me().getSysConfigValueWithDefault("ACCOUNT_ERROR_DETECTION", Boolean.class, false); + public static Integer getMaxErrorLoginCount() { + return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_MAX_ERROR_LOGIN_COUNT", Integer.class, LoginCacheConstants.MAX_ERROR_LOGIN_COUNT); } + } diff --git a/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java b/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java index babe7bdd5..a1dfbc69e 100644 --- a/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java +++ b/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java @@ -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.TenantCodeGetApi; 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.enums.SsoClientTypeEnum; 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.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.PasswordTransferEncryptApi; import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest; @@ -238,7 +238,7 @@ public class LoginService { */ private Integer validatePasswordRetryTimes(LoginRequest loginRequest) { 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); } return loginErrorCount;