本文介绍了在春季引导中将jsessonid cookie设置为SameSite = Strict属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将jsessionId cookie设置为SameSite = Strict的spring-boot配置是什么.
What is the spring-boot configuration to set jsessionId cookie as SameSite=Strict.
JsessionId需要添加SameSite = Strict或现有cookie,而不是新的cookie生成.它支持吗?
JsessionId need to add SameSite=Strict or existing cookie not new cookie generation.Is it support?
推荐答案
我使用Rfc6265CookieProcessor在Spring Boot应用程序中配置SameSite标志作为解决方法.
I used Rfc6265CookieProcessor to configure SameSite flag in the spring boot application as a workaround.
build.gradle :
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
...
}
在主类中进行配置:
@Bean
public ServletWebServerFactory servletContainer() {
return new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
Rfc6265CookieProcessor rfc6265CookieProcessor = new Rfc6265CookieProcessor();
rfc6265CookieProcessor.setSameSiteCookies("Strict");
context.setCookieProcessor(rfc6265CookieProcessor);
}
};
}
这篇关于在春季引导中将jsessonid cookie设置为SameSite = Strict属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!