mirror of https://gitee.com/stylefeng/roses
【8.0】【auth】整理登录相关配置位置
parent
c227eb1524
commit
956d50850c
|
@ -101,19 +101,6 @@ public class AuthConfigExpander {
|
|||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_SESSION_EXPIRED_SECONDS", Long.class, 3600L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单账号单端登录的开关
|
||||
* <p>
|
||||
* 单账号单端登录为限制一个账号多个浏览器登录
|
||||
*
|
||||
* @return true-开启单端限制,false-关闭单端限制
|
||||
* @author fengshuonan
|
||||
* @since 2020/10/21 14:31
|
||||
*/
|
||||
public static boolean getSingleAccountLoginFlag() {
|
||||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_SINGLE_ACCOUNT_LOGIN_FLAG", Boolean.class, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认解析jwt的秘钥(用于解析sso传过来的token)
|
||||
*
|
||||
|
@ -205,16 +192,4 @@ public class AuthConfigExpander {
|
|||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_AUTH_SSO_HOST", String.class, SYS_AUTH_SSO_HOST);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录密码是否进行RSA加密校验,默认关闭
|
||||
* <p>
|
||||
* 需要前端配合加密后再打开开关
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2022/10/16 23:28
|
||||
*/
|
||||
public static Boolean getPasswordRsaValidateFlag() {
|
||||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_AUTH_PASSWORD_RSA_VALIDATE", Boolean.class, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,4 +23,29 @@ public class LoginConfigExpander {
|
|||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_LOGIN_MAX_ERROR_LOGIN_COUNT", Integer.class, LoginCacheConstants.MAX_ERROR_LOGIN_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单账号单端登录的开关
|
||||
* <p>
|
||||
* 单账号单端登录为限制一个账号多个浏览器登录
|
||||
*
|
||||
* @return true-开启单端限制,false-关闭单端限制
|
||||
* @author fengshuonan
|
||||
* @since 2020/10/21 14:31
|
||||
*/
|
||||
public static boolean getSingleAccountLoginFlag() {
|
||||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_SINGLE_ACCOUNT_LOGIN_FLAG", Boolean.class, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录密码是否进行RSA加密校验,默认关闭
|
||||
* <p>
|
||||
* 需要前端配合加密后再打开开关
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2022/10/16 23:28
|
||||
*/
|
||||
public static Boolean getPasswordRsaValidateFlag() {
|
||||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_AUTH_PASSWORD_RSA_VALIDATE", Boolean.class, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ public class LoginService {
|
|||
sessionManagerApi.createSession(userLoginToken, loginUser);
|
||||
|
||||
// 11. 如果开启了单账号单端在线,则踢掉已经上线的该用户
|
||||
if (AuthConfigExpander.getSingleAccountLoginFlag()) {
|
||||
if (LoginConfigExpander.getSingleAccountLoginFlag()) {
|
||||
sessionManagerApi.removeSessionExcludeToken(userLoginToken);
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class LoginService {
|
|||
* @since 2023/6/20 23:15
|
||||
*/
|
||||
private void decryptRequestPassword(LoginRequest loginRequest) {
|
||||
if (loginRequest.getPassword() != null && AuthConfigExpander.getPasswordRsaValidateFlag()) {
|
||||
if (loginRequest.getPassword() != null && LoginConfigExpander.getPasswordRsaValidateFlag()) {
|
||||
String decryptPassword = passwordTransferEncryptApi.decrypt(loginRequest.getPassword());
|
||||
loginRequest.setPassword(decryptPassword);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.AuthJwtContext;
|
|||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
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.pojo.auth.LoginRequest;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginResponse;
|
||||
|
@ -211,7 +211,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||
sessionManagerApi.createSession(jwtToken, loginUser);
|
||||
|
||||
// 如果开启了单账号单端在线,则踢掉已经上线的该用户
|
||||
if (AuthConfigExpander.getSingleAccountLoginFlag()) {
|
||||
if (LoginConfigExpander.getSingleAccountLoginFlag()) {
|
||||
sessionManagerApi.removeSessionExcludeToken(jwtToken);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue