mirror of https://gitee.com/stylefeng/roses
【8.0】【auth】最大错误登录次数增加变量控制
parent
685cb81dbc
commit
c227eb1524
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 获取帐号错误次数校验开关
|
||||
* 登录账号密码登录最大的错误次数
|
||||
* <p>
|
||||
* 超过此次数则冻结账号
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue