提交 1ed42b1f authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

fix: 登录超时时间可配置

上级 65d18084
...@@ -13,6 +13,8 @@ import org.apache.commons.lang3.StringUtils; ...@@ -13,6 +13,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.core.env.Environment;
import java.util.Date; import java.util.Date;
...@@ -22,7 +24,9 @@ public class JWTUtils { ...@@ -22,7 +24,9 @@ public class JWTUtils {
// token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token ) // token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token )
private static final long EXPIRE_TIME = 1*60*1000; private static final long EXPIRE_TIME = 1*60*1000;
// 登录间隔时间10min 超过这个时间强制重新登录 // 登录间隔时间10min 超过这个时间强制重新登录
private static final long Login_Interval = 10*60*1000; private static long Login_Interval;
/** /**
...@@ -79,6 +83,11 @@ public class JWTUtils { ...@@ -79,6 +83,11 @@ public class JWTUtils {
* @return * @return
*/ */
public static boolean loginExpire(String token){ public static boolean loginExpire(String token){
if (Login_Interval==0) {
String property = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout");
int seconds = StringUtils.isNotEmpty(property) ? Integer.parseInt(property): (10*60);
Login_Interval = seconds * 1000;
}
Long now = System.currentTimeMillis(); Long now = System.currentTimeMillis();
Long lastOperateTime = tokenLastOperateTime(token); Long lastOperateTime = tokenLastOperateTime(token);
boolean isExpire = false; boolean isExpire = false;
...@@ -169,4 +178,5 @@ public class JWTUtils { ...@@ -169,4 +178,5 @@ public class JWTUtils {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
tokens_expire.put(token, now); tokens_expire.put(token, now);
} }
} }
...@@ -62,6 +62,10 @@ spring.mvc.log-request-details=true ...@@ -62,6 +62,10 @@ spring.mvc.log-request-details=true
pagehelper.PageRowBounds=true pagehelper.PageRowBounds=true
#excel等用户上传文件路径 #excel等用户上传文件路径
upload.file.path=/opt/dataease/data/upload/ upload.file.path=/opt/dataease/data/upload/
#用户初始密码,如果不设置默认是DataEase123..
dataease.init_password=DataEase123456
#登录超时时间单位s 设置默认30分钟 如果雨不设置 默认10分钟也就是10*60
dataease.login_timeout=1800
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论