title: Changing the login service URL in spring security
body: <p>Hi I have implemented Spring security in my spring boot web application with JWT filters. But the default authentication is happening at url <code>http://localhost:8080/login</code> . How to change <code>/login</code> to some url I need like <code>/rest/auth/login</code>?</p>
  
  <p>My <code>WebSecurity</code> class is</p>
  
  <pre><code>@EnableWebSecurity
  public class WebSecurity extends WebSecurityConfigurerAdapter {
  
  @Autowired
  private UserDetailsService userDetailsService;
  
  @Autowired
  private BCryptPasswordEncoder bCryptPasswordEncoder;
  
  public WebSecurity( UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder )
  {
      this.userDetailsService = userDetailsService;
      this.bCryptPasswordEncoder = bCryptPasswordEncoder;
  }
  
  @Override
  protected void configure( HttpSecurity http ) throws Exception
  {
      http.cors().and().csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/rest/auth/**").permitAll()
              .antMatchers("/static/*").permitAll().antMatchers("/").permitAll()
              /* .anyRequest().authenticated() */.and()
              .addFilter(new JWTAuthenticationFilter(authenticationManager()))
              .addFilter(new JWTAuthorizationFilter(authenticationManager()));
  }
  
  @Override
  public void configure( AuthenticationManagerBuilder auth ) throws Exception
  {
      auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
  }
  
  @Override
  public void configure( org.springframework.security.config.annotation.web.builders.WebSecurity web )
          throws Exception
  {
  
      web.ignoring().antMatchers("/static/**");
  }
  
  @Bean
  CorsConfigurationSource corsConfigurationSource()
  {
      final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
      source.registerCorsConfiguration("/**", new CorsConfiguration().applyPermitDefaultValues());
      return source;
  }
  }
  </code></pre>
  
  <p>I have a login page in my resource folder under static directory. The way Spring security works is, when user sends <code>userName</code> and <code>password</code> from the form, client has to send those credentials to <code>/login</code> path in the server, so that spring security verifies those credentials and creates token. But I want to change that default path <code>/login</code> to <code>/rest/auth/login</code></p>