title: Spring REST security - Secure different URLs differently for different user
body: <p>I am trying to provide security using spring boot security to the REST multiple endpoints with user wise but it is working for only one endpoint which depend on order and others don't work. Please suggest the solution. below my code replica </p>
  
  <pre><code>@EnableWebSecurity
  @EnableGlobalMethodSecurity(securedEnabled = true) 
  public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
  
    @Configuration
    @Order(0)
    public static class Api1WebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
  
        http.csrf().disable().authorizeRequests().antMatchers("/getEmployees/").authenticated()
            .and().httpBasic();
      }
  
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  
        auth.inMemoryAuthentication().withUser("bill").password("gates").roles("USER");
  
      }
  
    }
  
    @Configuration
    @Order(1)
    public static class Api2WebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
  
       http.csrf().disable().authorizeRequests().antMatchers("/getEmpId/).authenticated().and()
            .httpBasic();
      }
  
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  
        auth.inMemoryAuthentication().withUser("raj").password("simran").roles("USER");
  
      }
  
    }
  </code></pre>