|
|
@@ -0,0 +1,38 @@ |
|
|
|
package com.ningdatech.pmapi.user.security.auth.config; |
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.session.data.redis.RedisIndexedSessionRepository; |
|
|
|
import org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* 设置session的过期时间为一天 |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @Author LiuXinXin |
|
|
|
* @Date 2020/7/29 9:46 上午 |
|
|
|
* @Version 1.0 |
|
|
|
**/ |
|
|
|
@Configuration |
|
|
|
@RequiredArgsConstructor |
|
|
|
@AutoConfigureAfter(RedisHttpSessionConfiguration.class) |
|
|
|
public class RedisSessionTimeoutConfig { |
|
|
|
|
|
|
|
@Value("${spring.session.timeout:60 * 60 * 4}") |
|
|
|
private Integer springSessionTimeout; |
|
|
|
|
|
|
|
private final RedisHttpSessionConfiguration redisHttpSessionConfiguration; |
|
|
|
private final RedisIndexedSessionRepository redisIndexedSessionRepository; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void sessionTimeoutTime() { |
|
|
|
redisHttpSessionConfiguration.setMaxInactiveIntervalInSeconds(springSessionTimeout); |
|
|
|
redisIndexedSessionRepository.setDefaultMaxInactiveInterval(springSessionTimeout); |
|
|
|
} |
|
|
|
|
|
|
|
} |