title: Spring Security filters in Java configuration and multiple WebSecurityConfigurerAdapters
body: <p>Sorry to cross-post this here and the old spring forums, but I didn't get any responses and thought the original post may have gotten lost in the shuffle when the forums were deactivated. Anyhoo...</p>
  
  <p>From the documentation, one can mimic multiple  elements in the java config by extending WebSecurityConfigurerAdapter multiple times. I've done this, and added a couple custom filters to just one of them, but the odd thing is that the filters seem to be applied to all requests, even ones it shouldn't be matching. Here is a sample of my config:</p>
  
  <pre><code>@Configuration
  class ConfigA extends WebSecurityConfigurerAdapter {
      public void configure(HttpSecurity http) {
          http
            .antMatcher("/foo")
            .authorizeRequests()
                 .anyRequest().fullyAuthenticated()
                .and()
           .addFilterAfter(myFilter, BasicAuthFilter.class)
          ...
     }
  }
  
  @Configuration
  class ConfigB extends WebSecurityConfigurerAdapter {
      public void configure(HttpSecurity http) {
          http
            .antMatcher("/bar")
            .authorizeRequests()
                 .anyRequest().fullyAuthenticated()
                .and()
  ​         ...
     }
  }
  </code></pre>
  
  <p>What am I missing? Is this by design that that filter is applied to both/all requests? Is the filter itself supposed to figure out which requests it should apply to?</p>
  
  <p>Thanks,
  Justin</p>