Spring Security-如何在某些URL模式中删除缓存控制 [英] spring security - how to remove cache control in certain url pattern

查看:305
本文介绍了Spring Security-如何在某些URL模式中删除缓存控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试过滤某些URL模式以进行缓存. 我试图将一些代码放入WebSecurityConfigurerAdapter实现中.

I am trying to filter some url pattern to caching. What I have attempted is put some codes into WebSecurityConfigurerAdapter implementation.

 @Override
protected void configure(HttpSecurity http) throws Exception {
    initSecurityConfigService();

    // For cache
    http.headers().defaultsDisabled()
            .cacheControl()
            .and().frameOptions();

    securityConfigService.configure(http,this);
}

但是,此代码将影响所有Web应用程序.我如何将其应用于某些URLContent-Type,例如images.

However this code will effect all of the web application. How can I apply this to certain URL or Content-Type like images.

我已经尝试过RegexRequestMatcher,但是它对我不起作用.

I have already tried with RegexRequestMatcher, but it does not work for me.

// For cache
        http.requestMatcher(new RegexRequestMatcher("/page/", "GET"))
                .headers().defaultsDisabled()
                .cacheControl()
                .and().frameOptions();

我阅读了这篇文章: SpringSecurityResponseHeaders ,但是这种情况下没有示例.

I read this article : SpringSecurityResponseHeaders, but there is no sample for this case.

谢谢.

P.S.简而言之,我想删除某些网址和资源的SpringSecurity defaults.

P.S. In short, I want to remove SpringSecurity defaults for certain url and resources.

推荐答案

拥有多个WebSecurityConfigurerAdapters怎么办?一个适配器可能具有对某些URL的缓存控制,而另一个适配器则没有为那些URL启用缓存控制.

What about having multiple WebSecurityConfigurerAdapters? One adapter could have cache controls for certain URLs and another one will not have cache control enabled for those URLs.

这篇关于Spring Security-如何在某些URL模式中删除缓存控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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