From a31dd243991b48562c844fad67da924e9ec936f9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 20 Jul 2024 18:42:19 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=85=A8=E5=B1=80=EF=BC=9ALoginUser=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=BF=87=E6=9C=9F=E6=97=B6=E9=97=B4=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E5=88=A4=E6=96=AD=20token=20=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/json}/databind/NumberSerializer.java | 2 +- .../json}/databind/TimestampLocalDateTimeDeserializer.java | 2 +- .../json}/databind/TimestampLocalDateTimeSerializer.java | 2 +- .../cn/iocoder/yudao/framework/security/core/LoginUser.java | 5 +++++ .../security/core/filter/TokenAuthenticationFilter.java | 3 ++- .../jackson/config/YudaoJacksonAutoConfiguration.java | 6 +++--- .../api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java | 5 +++++ 7 files changed, 18 insertions(+), 7 deletions(-) rename yudao-framework/{yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core => yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json}/databind/NumberSerializer.java (95%) rename yudao-framework/{yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core => yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json}/databind/TimestampLocalDateTimeDeserializer.java (93%) rename yudao-framework/{yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core => yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json}/databind/TimestampLocalDateTimeSerializer.java (92%) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/NumberSerializer.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/NumberSerializer.java similarity index 95% rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/NumberSerializer.java rename to yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/NumberSerializer.java index f6ddd3f27..35fc9f72c 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/NumberSerializer.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/NumberSerializer.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.jackson.core.databind; +package cn.iocoder.yudao.framework.common.util.json.databind; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/TimestampLocalDateTimeDeserializer.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/TimestampLocalDateTimeDeserializer.java similarity index 93% rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/TimestampLocalDateTimeDeserializer.java rename to yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/TimestampLocalDateTimeDeserializer.java index 71a480fbf..5bf5d6c63 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/TimestampLocalDateTimeDeserializer.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/TimestampLocalDateTimeDeserializer.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.jackson.core.databind; +package cn.iocoder.yudao.framework.common.util.json.databind; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/TimestampLocalDateTimeSerializer.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/TimestampLocalDateTimeSerializer.java similarity index 92% rename from yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/TimestampLocalDateTimeSerializer.java rename to yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/TimestampLocalDateTimeSerializer.java index e72c47bb8..ef767a558 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/core/databind/TimestampLocalDateTimeSerializer.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/databind/TimestampLocalDateTimeSerializer.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.jackson.core.databind; +package cn.iocoder.yudao.framework.common.util.json.databind; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java index 68d1c5611..e23c3a7a2 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/LoginUser.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; +import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,6 +43,10 @@ public class LoginUser { * 授权范围 */ private List scopes; + /** + * 过期时间 + */ + private LocalDateTime expiresTime; // ========== 上下文 ========== /** diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java index bc7ff8a9a..cbd91ee57 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/filter/TokenAuthenticationFilter.java @@ -84,7 +84,8 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter { // 构建登录用户 return new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) .setInfo(accessToken.getUserInfo()) // 额外的用户信息 - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()); + .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()) + .setExpiresTime(accessToken.getExpiresTime()); } catch (ServiceException serviceException) { // 校验 Token 不通过时,考虑到一些接口是无需登录的,所以直接返回 null 即可 return null; diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java index 4f94f16ec..c62f0a030 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java @@ -2,9 +2,9 @@ package cn.iocoder.yudao.framework.jackson.config; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.jackson.core.databind.NumberSerializer; -import cn.iocoder.yudao.framework.jackson.core.databind.TimestampLocalDateTimeDeserializer; -import cn.iocoder.yudao.framework.jackson.core.databind.TimestampLocalDateTimeSerializer; +import cn.iocoder.yudao.framework.common.util.json.databind.NumberSerializer; +import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeDeserializer; +import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeSerializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java index 933210442..c678b48a6 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/oauth2/dto/OAuth2AccessTokenCheckRespDTO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.api.oauth2.dto; import lombok.Data; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -34,5 +35,9 @@ public class OAuth2AccessTokenCheckRespDTO implements Serializable { * 授权范围的数组 */ private List scopes; + /** + * 过期时间 + */ + private LocalDateTime expiresTime; }