2

A web.xml makes registering the order of an application's filters obvious/explicit. But, I'm using Java Config. I define a filter, MyProcessingFilter.java, which extends AbstractAuthenticationProcessingFilter. In the filter chain, I need to make sure that it comes after Spring Security's SecurityContextPersistenceFilter. See essential Spring Security filter ordering.

I'm using Spring Boot. This is how I declare my filter

@Configuration
public class Config {

    /*...*/

    @Bean
    public Filter myProcessingFilter() {
        MyProcessingFilter myProcessingFilter = new MyProcessingFilter(AnyRequestMatcher.INSTANCE);
        myProcessingFilter.setAuthenticationManager(authenticationManager());
        return myProcessingFilter;
    }
}

Spring Boot orders this custom filter first.

Basically, I have a custom authentication filter and I need it to come after Spring Security's SecurityContextPersistenceFilter. Any suggestions?

David Groomes
  • 2,303
  • 1
  • 21
  • 23
  • 1
    possible duplicate of [How to define Servlet filter order of execution in Spring Boot application](http://stackoverflow.com/questions/22453707/how-to-define-servlet-filter-order-of-execution-in-spring-boot-application) – Serge Ballesta Nov 07 '14 at 23:25
  • I suspect that you want your filter to actually be part of the spring security filter chain and not after the chain. Judging by the bean you are injecting you have provided your own authentication filter. – M. Deinum Nov 10 '14 at 06:53

0 Answers0