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

fix: 解决由于缓存过期导致登录超时失效的bug

上级 180c56f2
...@@ -6,7 +6,6 @@ import io.dataease.auth.entity.TokenInfo; ...@@ -6,7 +6,6 @@ import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.service.AuthUserService; import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils; import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.commons.utils.ServletUtils;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
......
...@@ -84,24 +84,17 @@ public class JWTUtils { ...@@ -84,24 +84,17 @@ public class JWTUtils {
*/ */
public static boolean loginExpire(String token){ public static boolean loginExpire(String token){
if (Login_Interval==0) { if (Login_Interval==0) {
String property = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout"); int minute = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Integer.class, 8*60);
// 默认超时时间是8h
int minute = StringUtils.isNotEmpty(property) ? Integer.parseInt(property): (8*60);
// 分钟换算成毫秒 // 分钟换算成毫秒
Login_Interval = minute * 1000 * 60; Login_Interval = minute * 1000 * 60;
} }
Long now = System.currentTimeMillis(); Long now = System.currentTimeMillis();
Long lastOperateTime = tokenLastOperateTime(token); Long lastOperateTime = tokenLastOperateTime(token);
if (ObjectUtils.isEmpty(lastOperateTime)) return true;
boolean isExpire = false; boolean isExpire = false;
if (lastOperateTime != null) { if (lastOperateTime != null) {
isExpire = now - lastOperateTime > Login_Interval; isExpire = now - lastOperateTime > Login_Interval;
} }
if (isExpire) {
// System.out.println("-----------------------");
// System.out.println("-----上次操作时间是["+lastOperateTime+"]-----");
// System.out.println("-----当前操作时间是["+now+"]-----");
// System.out.println("-----------------------");
}
return isExpire; return isExpire;
} }
...@@ -116,7 +109,7 @@ public class JWTUtils { ...@@ -116,7 +109,7 @@ public class JWTUtils {
} }
/** /**
* 生成签名,5min后过期 * 生成签名,1min后过期
* @param tokenInfo 用户信息 * @param tokenInfo 用户信息
* @param secret 用户的密码 * @param secret 用户的密码
* @return 加密的token * @return 加密的token
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<defaultCache <defaultCache
eternal="false" eternal="false"
maxElementsInMemory="1000" maxElementsInMemory="1000"
overflowToDisk="false" overflowToDisk="true"
diskPersistent="false" diskPersistent="false"
timeToIdleSeconds="0" timeToIdleSeconds="0"
timeToLiveSeconds="600" timeToLiveSeconds="600"
...@@ -38,46 +38,46 @@ ...@@ -38,46 +38,46 @@
<cache <cache
name="users_info" name="users_info"
eternal="false" eternal="false"
maxElementsInMemory="100" maxElementsInMemory="1000"
maxElementsOnDisk="1000" maxElementsOnDisk="0"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="true" diskPersistent="false"
timeToIdleSeconds="1800" timeToIdleSeconds="28800"
timeToLiveSeconds="3600" timeToLiveSeconds="36000"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
<cache <cache
name="users_roles_info" name="users_roles_info"
eternal="false" eternal="false"
maxElementsInMemory="100" maxElementsInMemory="1000"
maxElementsOnDisk="1000" maxElementsOnDisk="0"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="true" diskPersistent="false"
timeToIdleSeconds="1800" timeToIdleSeconds="28800"
timeToLiveSeconds="3600" timeToLiveSeconds="36000"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
<cache <cache
name="users_permissions_info" name="users_permissions_info"
eternal="false" eternal="false"
maxElementsInMemory="100" maxElementsInMemory="1000"
maxElementsOnDisk="1000" maxElementsOnDisk="0"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="true" diskPersistent="false"
timeToIdleSeconds="1800" timeToIdleSeconds="28800"
timeToLiveSeconds="3600" timeToLiveSeconds="36000"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
<cache <cache
name="tokens_expire" name="tokens_expire"
eternal="false" eternal="false"
maxElementsInMemory="100" maxElementsInMemory="1000"
maxElementsOnDisk="1000" maxElementsOnDisk="0"
overflowToDisk="true" overflowToDisk="true"
diskPersistent="true" diskPersistent="false"
timeToIdleSeconds="1800" timeToIdleSeconds="28800"
timeToLiveSeconds="3600" timeToLiveSeconds="36000"
memoryStoreEvictionPolicy="LRU" memoryStoreEvictionPolicy="LRU"
/> />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论