this is 4.2 update
This commit is contained in:
parent
4a6047bd22
commit
f5bf0bcdad
9
pom.xml
9
pom.xml
|
@ -209,6 +209,15 @@
|
|||
<version>3.5.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-core</artifactId>
|
||||
<version>3.4.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.cultural.heritage.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.session.DefaultCookieSerializerCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.session.MapSessionRepository;
|
||||
import org.springframework.session.SessionRepository;
|
||||
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Configuration
|
||||
@EnableSpringHttpSession
|
||||
public class SessionConfig {
|
||||
|
||||
@Bean
|
||||
public SessionRepository sessionRepository() {
|
||||
return new MapSessionRepository(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
DefaultCookieSerializerCustomizer cookieSerializerCustomizer() {
|
||||
return cookieSerializer -> {
|
||||
cookieSerializer.setSameSite("None"); // 设置cookie的SameSite属性为None,否则跨域set-cookie会被chrome浏览器阻拦
|
||||
cookieSerializer.setUseSecureCookie(true); // sameSite为None时,useSecureCookie必须为true
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user