From 07bd8a6eecb30cf54726e4fb5a2d2179c945db51 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 6 May 2024 10:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AEcookiePath=E7=9A=84=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java | 4 ++++ kq-vas-api/src/main/resources/application-dev.yml | 3 +++ kq-vas-api/src/main/resources/application-pre.yml | 3 +++ kq-vas-api/src/main/resources/application-prod.yml | 3 +++ 4 files changed, 13 insertions(+) diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java index 4103f92..0293b85 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java @@ -34,6 +34,9 @@ public class RedisSessionConfig { @Value("${nd.cache.def.keyPrefix:}") private String keyPrefix; + @Value("${cookie.path}") + private String cookiePath; + public String getRedisNamespace() { return (StrUtil.isBlank(keyPrefix) ? StrPool.EMPTY : keyPrefix + StrPool.COLON) + RedisIndexedSessionRepository.DEFAULT_NAMESPACE; } @@ -45,6 +48,7 @@ public class RedisSessionConfig { // 创建 DefaultCookieSerializer 对象 DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer(); cookieSerializer.setCookieName(BizConst.COOKIE_KEY); + cookieSerializer.setCookiePath(cookiePath); cookieSerializer.setCookieMaxAge(AuthConst.SESSION_TIME_SECONDS); // 设置到 sessionIdResolver 中 sessionIdResolver.setCookieSerializer(cookieSerializer); diff --git a/kq-vas-api/src/main/resources/application-dev.yml b/kq-vas-api/src/main/resources/application-dev.yml index 03e653a..a458a40 100644 --- a/kq-vas-api/src/main/resources/application-dev.yml +++ b/kq-vas-api/src/main/resources/application-dev.yml @@ -4,6 +4,9 @@ server: context-path: /kq shutdown: graceful +cookie: + path: ${server.servlet.context-path} + spring: mvc: pathmatch: diff --git a/kq-vas-api/src/main/resources/application-pre.yml b/kq-vas-api/src/main/resources/application-pre.yml index 137cf86..c2b463b 100644 --- a/kq-vas-api/src/main/resources/application-pre.yml +++ b/kq-vas-api/src/main/resources/application-pre.yml @@ -4,6 +4,9 @@ server: context-path: /kq shutdown: graceful +cookie: + path: /dev/kq + spring: mvc: pathmatch: diff --git a/kq-vas-api/src/main/resources/application-prod.yml b/kq-vas-api/src/main/resources/application-prod.yml index b4d1386..8d96540 100644 --- a/kq-vas-api/src/main/resources/application-prod.yml +++ b/kq-vas-api/src/main/resources/application-prod.yml @@ -4,6 +4,9 @@ server: context-path: /kq shutdown: graceful +cookie: + path: ${server.servlet.context-path} + spring: mvc: pathmatch: