diff --git a/pqs-gateway/src/main/java/com/njcn/gateway/filter/AuthGlobalFilter.java b/pqs-gateway/src/main/java/com/njcn/gateway/filter/AuthGlobalFilter.java index 7b91aced3..686aeeee3 100644 --- a/pqs-gateway/src/main/java/com/njcn/gateway/filter/AuthGlobalFilter.java +++ b/pqs-gateway/src/main/java/com/njcn/gateway/filter/AuthGlobalFilter.java @@ -1,5 +1,6 @@ package com.njcn.gateway.filter; +import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; @@ -29,6 +30,7 @@ import reactor.core.publisher.Mono; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; @@ -73,6 +75,11 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered { JSONObject jsonObject = JSONUtil.parseObj(payload); String userIndex = jsonObject.getStr(SecurityConstants.USER_INDEX_KEY); String jti = jsonObject.getStr(SecurityConstants.JWT_JTI); + String exp = jsonObject.getStr(SecurityConstants.JWT_EXP); + LocalDateTime expTime = LocalDateTimeUtil.of(Long.parseLong(exp + "000")); + if(expTime.isAfter(LocalDateTimeUtil.now())){ + return ResponseUtils.writeErrorInfo(response, GateWayEnum.ACCESS_TOKEN_EXPIRE_JWT); + } String blackUserKey = SecurityConstants.TOKEN_BLACKLIST_PREFIX + userIndex; List blackUsers = (List) redisUtil.getObjectByKey(blackUserKey); if (CollectionUtils.isNotEmpty(blackUsers)) { @@ -96,4 +103,5 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered { public int getOrder() { return 0; } + }