How to enable samesite for jsessionid cookie

后端 未结 4 1764
时光说笑
时光说笑 2020-12-15 21:32

How can I enable samesite for my web application which runs on wildfly as. Checked standalone.xml however could not find an appropriate tag within



        
4条回答
  •  星月不相逢
    2020-12-15 22:20

    For Spring Boot with the currently latest release:

    If you do not have the latest spring-boot-starter-tomcat check the SameSiteCookies enum for value UNSET, if the value is missing you need a newer release because it will skip the value SameSite=None.

    @Component
    public class SameSiteTomcatCookieProcessorCustomizationBean implements WebServerFactoryCustomizer
    {
        @Override
        public void customize(TomcatServletWebServerFactory server) {
    
            server.getTomcatContextCustomizers().add(new TomcatContextCustomizer()
            {
                @Override
                public void customize(Context context)
                {
                    Rfc6265CookieProcessor cookieProcessor = new Rfc6265CookieProcessor();
                    cookieProcessor.setSameSiteCookies("None");
                    context.setCookieProcessor(cookieProcessor);
                }
            });
        }
    }
    

提交回复
热议问题