title: Redirect for logout Spring Security
body: <p>I use the following Spring security configuraiton for my    @Override</p>
  
  <pre><code>protected void configure(HttpSecurity http) throws Exception {
      http
          .csrf().disable()
          .authorizeRequests()
              .antMatchers("/login").permitAll()
          .and()
          .authorizeRequests()
              .antMatchers("/signup").permitAll()
          .and()
          .authorizeRequests()
              .anyRequest().authenticated()
          .and()
              .logout().logoutUrl("/logout").logoutSuccessUrl("/login").deleteCookies("auth_code").invalidateHttpSession(true)
          .and()
          // We filter the api/signup requests
          .addFilterBefore(
              new JWTSignupFilter("/signup", authenticationManager(),
                      accountRepository, passwordEncoder),
              UsernamePasswordAuthenticationFilter.class)
          // We filter the api/login requests
          .addFilterBefore(
              new JWTLoginFilter("/login", authenticationManager()),
              UsernamePasswordAuthenticationFilter.class)
          // And filter other requests to check the presence of JWT in
          // header
          .addFilterBefore(new JWTAuthenticationFilter(userDetailsServiceBean()),
              UsernamePasswordAuthenticationFilter.class);
  }
  </code></pre>
  
  <p>I want browser to be redirected to <code>/login</code> URL in result of successful logout. But I get this response:</p>
  
  <pre><code>{
    "timestamp": 1493871686489,
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/login"
  }
  </code></pre>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I have a login filter which captures POST requests to the <code>/login</code> endpoint:</p>
  
  <pre><code>public class JWTLoginFilter extends AbstractAuthenticationProcessingFilter {
  
  
      public JWTLoginFilter(String url, AuthenticationManager authManager) {
          super(new AntPathRequestMatcher(url, "POST"));
          setAuthenticationManager(authManager);
      }
  
      @Override
      public Authentication attemptAuthentication(HttpServletRequest req,
              HttpServletResponse res) throws AuthenticationException,
              IOException, ServletException {
  
          CustomUserDetails creds = new ObjectMapper().readValue(
                  req.getInputStream(), CustomUserDetails.class);
  
          return getAuthenticationManager().authenticate(
                  new UsernamePasswordAuthenticationToken(creds.getUsername(),
                          creds.getPassword()));
      }
  
      @Override
      protected void successfulAuthentication(HttpServletRequest req,
              HttpServletResponse res, FilterChain chain, Authentication auth) {
          TokenAuthenticationService.addAuthentication(res, auth.getName());
      }
  }
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>The following rest controller doesn't get hit ! </p>
  
  <pre><code>@RestController
  public class UserAcccountController {
      @Autowired
      AccountRepository accountRepository;
  
      @RequestMapping(path = "/login", method = RequestMethod.GET)
      public String loginGet() {
          return "/login";
      }
  
      @RequestMapping(path = "/login", method = RequestMethod.POST)
      public void loginPost(HttpServletResponse httpServletResponse) {
          httpServletResponse.setHeader("Location", "/home");
      }
  
  }
  </code></pre>