spring security - how to remove cache control in certain url pattern

前端 未结 2 1319
日久生厌
日久生厌 2021-01-14 13:16

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

 @O         


        
相关标签:
2条回答
  • 2021-01-14 13:59

    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.

    0 讨论(0)
  • 2021-01-14 14:01

    I solved this with Filter. Below is part of my implementation of AbstractAnnotationConfigDispatcherServletInitializer. In onStartup method override.

    FilterRegistration.Dynamic springSecurityFilterChain = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    if(springSecurityFilterChain != null){
        springSecurityFilterChain.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/render/*", "/service/*");
        // I removed pattern url "/image/*" :)
    }
    

    What I have done is remove /image/* from MappingUrlPatterns. Thanks for your answers!

    0 讨论(0)
提交回复
热议问题