spring引导defaultcookieserializercustomizer不工作

xtfmy6hx  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(359)

尝试让defaultcookieserializercustomizer在我的springboot应用程序(2.3.6)中工作以覆盖samesite会话cookie选项。

package com.backend;

...
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.session.DefaultCookieSerializerCustomizer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;

@SpringBootApplication
@EnableWebSecurity
public class Backend extends SpringBootServletInitializer {
...
    @Bean
    public DefaultCookieSerializerCustomizer defaultCookieSerializerCustomizer() {
        return cookieSerializer -> {
            LOG.info("Some cookie action");
            cookieSerializer.setSameSite("None");
        };
    }
...

不幸的是,信息记录只在战争部署时出现。没有cookie更改。有什么想法吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题