refactor(gateway): 重写is-login方法,不用响应式,防止阻塞redisson线程

This commit is contained in:
liqiang-fit2cloud 2023-04-28 18:05:30 +08:00
parent 4513353ae3
commit 892b938313
1 changed files with 11 additions and 0 deletions

View File

@ -1,18 +1,29 @@
package io.metersphere.gateway.config;
import io.metersphere.commons.constants.SessionConstants;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.session.data.redis.RedisSessionRepository;
import org.springframework.web.server.session.HeaderWebSessionIdResolver;
import org.springframework.web.server.session.WebSessionIdResolver;
@Configuration
public class SessionConfig {
@Resource
private RedisTemplate<String, Object> redisTemplate;
@Bean
public WebSessionIdResolver webSessionIdResolver() {
HeaderWebSessionIdResolver sessionIdResolver = new HeaderWebSessionIdResolver();
sessionIdResolver.setHeaderName(SessionConstants.HEADER_TOKEN); // Define Session Header Name
return sessionIdResolver;
}
@Bean
public RedisSessionRepository redisSessionRepository() {
return new RedisSessionRepository(redisTemplate);
}
}