title: Multiple WebSecurityConfigurerAdapter in spring boot for multiple patterns
body: <p>I am trying to set up multiple WebsecurityConfigurerAdapter for my project where the spring boot actuator APIs are secured using basic auth and all other endpoints are authenticated using JWtAuthentication. I am just not able to make it work together, only the config with the lower order works.  I am using Spring Boot 2.1.5.RELEASE</p>
  <p>Security Config One with JWT Authenticator</p>
  <pre><code>@Order(1)
  @Configuration
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      private static final String[] AUTH_WHITELIST = {
          &quot;/docs/**&quot;,
          &quot;/csrf/**&quot;,
          &quot;/webjars/**&quot;,
          &quot;/**swagger**/**&quot;,
          &quot;/swagger-resources&quot;,
          &quot;/swagger-resources/**&quot;,
          &quot;/v2/api-docs&quot;
      };
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests()
              .antMatchers(AUTH_WHITELIST).permitAll()
              .antMatchers(&quot;/abc/**&quot;, &quot;/abc/pdf/**&quot;).hasAuthority(&quot;ABC&quot;)
              .antMatchers(&quot;/ddd/**&quot;).hasAuthority(&quot;DDD&quot;)
              .and()
              .csrf().disable()
              .oauth2ResourceServer().jwt().jwtAuthenticationConverter(new GrantedAuthoritiesExtractor());
     }
  }
  </code></pre>
  <p>The basic Auth config with username/password</p>
  <pre><code>@Order(2)
  @Configuration
  public class ActuatorSecurityConfig extends WebSecurityConfigurerAdapter {
  
  /*    @Bean
  public UserDetailsService userDetailsService(final PasswordEncoder encoder) {
      final InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
      manager.createUser(
              User
                      .withUsername(&quot;user1&quot;)
                      .password(encoder.encode(&quot;password&quot;))
                      .roles(&quot;ADMIN&quot;)
                      .build()
      );
      return manager;
  }
  
  @Bean PasswordEncoder encoder(){
      return new BCryptPasswordEncoder();
  }*/
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
      http.authorizeRequests()
              .antMatchers(&quot;/actuator/**&quot;).hasRole(&quot;ADMIN&quot;)
              .and()
              .httpBasic();
  }
  
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.inMemoryAuthentication().withUser(&quot;user1&quot;).password(&quot;password&quot;).authorities(&quot;ADMIN&quot;);
    }
  }
  </code></pre>
  <p>I have been trying to make it work for many days but cannot make both of them work together. If i swap the order, only basic auth works and not the JWT Auth Manager.</p>
  <p>I have gone through a lot of SOF Questions, like</p>
  <p>[https://stackoverflow.com/questions/40743780/spring-boot-security-multiple-websecurityconfigureradapter][1]</p>
  <p>[https://stackoverflow.com/questions/52606720/issue-with-having-multiple-websecurityconfigureradapter-in-spring-boot][1]</p>
  <p>[https://github.com/spring-projects/spring-security/issues/5593][1]</p>
  <p>[https://www.baeldung.com/spring-security-multiple-entry-points][1]</p>
  <p>Nothing seems to be working, is this a known issue in Spring?</p>