From da387cc39d1719219f76f542a02a37940e8e2fe7 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Mon, 29 Jul 2024 11:48:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=88=A4=E6=96=ADaccess?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/njcn/gateway/filter/AuthGlobalFilter.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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; } + }