在春季引导中将jsessonid cookie设置为SameSite = Strict属性吗? [英] Setting jsessonid cookie to SameSite=Strict attribute in spring boot?

查看:64
本文介绍了在春季引导中将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属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆