title: Spring security - Getting 404 error for REST call
body: <p>I have an application that I am securing using Spring Security.  I enable it using the annotations:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  </code></pre>
  
  <p>I then configure it by overriding the configure() method:</p>
  
  <pre><code>@Override
  protected void configure(HttpSecurity http) throws Exception {
      http
          .csrf()
      .and()
          .addFilterAfter(new CsrfCookieGeneratorFilter(), CsrfFilter.class)
          .exceptionHandling()
          .accessDeniedHandler(new CustomAccessDeniedHandler())
          .authenticationEntryPoint(authenticationEntryPoint)
      .and()
          .formLogin()
          .loginProcessingUrl("/api/authentication")
          .successHandler(ajaxAuthenticationSuccessHandler)
          .failureHandler(ajaxAuthenticationFailureHandler)
          .usernameParameter("username")
          .passwordParameter("password")
          .permitAll()
      .and()
          .logout()
          .logoutUrl("/api/logout")
          .logoutSuccessHandler(ajaxLogoutSuccessHandler)
          .deleteCookies("JSESSIONID", "CSRF-TOKEN")
          .permitAll()
      .and()
          .headers()
          .frameOptions()
          .disable()
      .and()
          .authorizeRequests()
          .antMatchers("/api/**").authenticated()
          .antMatchers("/admin/**").hasAuthority(AuthoritiesConstants.ADMIN);
  }
  </code></pre>
  
  <p>I'm getting redirected correctly to the login page when I try to get to the home page, but once I enter my credentials and try to login, I get the 404 not found error for /api/authentication REST call.</p>
  
  <p>The loginProcessingUrl() method specifies the call to make.  I don't have to implement this myself do I, as Spring should do that for me?  Is there anything else I'm missing?</p>