title: How do I configure a WebSecurityContext with filters that depend on other beans with Spring Security?
body: <p>How do I configure a WebSecurityContext with filters that depend on other beans with Spring Security?</p>
  <p>I am creating a plugin support for our authentication service, and that's what I am trying to do:</p>
  <pre class="lang-java prettyprint-override"><code>@Configuration
  @EnableWebSecurity
  @Order(1)
  @ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = AuthPlugin.class))
  public class AuthPluginSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Override
      protected void configure(final HttpSecurity http) throws Exception {
          http.addFilterAfter(new AuthPluginFilter(), AbstractPreAuthenticatedProcessingFilter.class);
      }
  }
  </code></pre>
  <p>Now, my <code>AuthPluginFilter</code> will of course depend on other beans, the implementations of the plugin, for example.</p>
  <p>But this wouldn't work, as <code>configure</code> is overwritten from <code>WebSecurityConfigurerAdapter</code>:</p>
  <pre class="lang-java prettyprint-override"><code>    @Override
      protected void configure(final HttpSecurity http, List&lt;AuthPlugin&gt; authPlugins) throws Exception {
          http.addFilterAfter(new AuthPluginFilter(authPlugins), AbstractPreAuthenticatedProcessingFilter.class);
      }
  </code></pre>
  <p>I can think of workarounds with <code>@Autowired</code> annotations at the fields. But I'd like to avoid this, if possible.</p>
  <p>Is there a more beautiful, recommended way of doing this?</p>