Browse Source

设置cookiePath的访问路径

master
WendyYang 7 months ago
parent
commit
07bd8a6eec
4 changed files with 13 additions and 0 deletions
  1. +4
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java
  2. +3
    -0
      kq-vas-api/src/main/resources/application-dev.yml
  3. +3
    -0
      kq-vas-api/src/main/resources/application-pre.yml
  4. +3
    -0
      kq-vas-api/src/main/resources/application-prod.yml

+ 4
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java View File

@@ -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);


+ 3
- 0
kq-vas-api/src/main/resources/application-dev.yml View File

@@ -4,6 +4,9 @@ server:
context-path: /kq
shutdown: graceful

cookie:
path: ${server.servlet.context-path}

spring:
mvc:
pathmatch:


+ 3
- 0
kq-vas-api/src/main/resources/application-pre.yml View File

@@ -4,6 +4,9 @@ server:
context-path: /kq
shutdown: graceful

cookie:
path: /dev/kq

spring:
mvc:
pathmatch:


+ 3
- 0
kq-vas-api/src/main/resources/application-prod.yml View File

@@ -4,6 +4,9 @@ server:
context-path: /kq
shutdown: graceful

cookie:
path: ${server.servlet.context-path}

spring:
mvc:
pathmatch:


Loading…
Cancel
Save