title: Spring Custom Filter is always invoked
body: <p>I have a custom filter which is called before BasicAuthenticationFilter, the Bean is autowired in the SecurityConfig file.</p>
  
  <pre><code>.addFilterBefore(preAuthTenantContextInitializerFilter, BasicAuthenticationFilter.class)
  </code></pre>
  
  <p>Here is how the filter looks like.</p>
  
  <pre><code>@Component
  public class PreAuthTenantContextInitializerFilter extends OncePerRequestFilter {
      @Autowired
      private TenantService tenantService;
  .....
  .....
  </code></pre>
  
  <p>I want this filter to not fire just like the rest of the Spring Security filter chain for paths included in WebSecurityConfigurerAdapter#configure(WebSecurity web) web.ignoring().</p>
  
  <p>Here is how it looks like</p>
  
  <pre><code>@Configuration
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
      @Override
      public void configure(WebSecurity web) throws Exception {
          web.ignoring().antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources", 
                                      "/configuration/security", "/swagger-ui.html", 
                                      "/webjars/**","/swagger-resources/configuration/ui",
                                      "/swagge‌​r-ui.html", "/docs/**");
      }
  }
  </code></pre>
  
  <p><strong>What I have already tried.</strong></p>
  
  <p>Remove the @Component annotation from the filter class, it only prevented the filter from invoking in any case since the filter is no more picked as a bean and will never make it to the filter chain.</p>
  
  <p><strong>What I am looking for</strong></p>
  
  <p>I want this filter to be called when the rest of the Spring Security chain is called and be ignored for the paths in web.ignoring() just like the rest of the Spring Security filters. Thanks.</p>