title: How to configure multiple HttpSecurity with UserDetailsService using spring boot security?
body: <p>I'm working on with spring boot security layer to authenticate and authorize the user.Now, i would like to do some sample app using multi http security configuration.I have the scenario like there will be two login pages with different URL mappings("/managementLogin","/othersLogin").</p>
  
  <p>I can understood how to configure multi httpsecurity configs but i need to validate the users from two tables.If the management users loggedIn i need to validate the user from management table through DAO layer using <code>UserDetailsService</code> else if any other users loggedIn i need to validate from other_users table.</p>
  
  <p>Could anybody help me to know how to configure the multi http config and dao layer using <code>UserDetailsService</code> with spring boot security ?</p>
  
  <p>Here is my basic code snippet,</p>
  
  <pre><code>@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
  public class ApplicationSecurity extends WebSecurityConfigurerAdapter {
  
  
      @Autowired
      @Qualifier("userDetailsService")
      UserDetailsService userDetailsService;
  
      @Autowired
      private RESTAuthenticationEntryPoint authenticationEntryPoint;
  
      @Autowired
      private RESTAuthenticationFailureHandler authenticationFailureHandler;
      @Autowired
      private RESTAuthenticationSuccessHandler authenticationSuccessHandler;
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          // for testing authentication purpose using inMemory db
          /*
           * auth.inMemoryAuthentication().withUser("user").password("user").roles
           * ("USER").and().withUser("admin") .password("admin").roles("ADMIN");
           */
  
          // Dao based authentication
          auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests().antMatchers("/", "/home").permitAll();
          http.authorizeRequests().antMatchers("/rest/**").authenticated();
          http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
          http.formLogin().successHandler(authenticationSuccessHandler);
          http.formLogin().failureHandler(authenticationFailureHandler);
          http.logout().logoutSuccessUrl("/");
  
          // CSRF tokens handling
          http.addFilterAfter(new CsrfTokenResponseHeaderBindingFilter(), CsrfFilter.class);
      }
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          web
            .ignoring()
            .antMatchers("/registerUser","/register.html");
      }
  
      @Bean
      public PasswordEncoder passwordEncoder() {
          PasswordEncoder encoder = new BCryptPasswordEncoder();
          return encoder;
      }
  }
  </code></pre>
  
  <p>TIA..,</p>