title: Append intended target URL when user is not authenticated with Spring Security
body: <p>I'm currently using a <code>SavedRequestAwareAuthenticationSuccessHandler</code> with targetUrlParameter as follows:</p>
  <pre><code>@Configuration
  @EnableWebSecurity
  @RequiredArgsConstructor
  @EnableGlobalMethodSecurity(prePostEnabled = true)
  public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
  
    @Override
    protected void configure(HttpSecurity http) throws Exception {
      http.authorizeRequests()
          .antMatchers(&quot;/login**&quot;, &quot;/actuator/**&quot;).permitAll()
          .anyRequest().authenticated()
          .and()
          .formLogin().loginPage(&quot;/login&quot;).permitAll().successHandler(authenticationSuccessHandler())
          .failureHandler(authenticationFailureHandler())
          .and()
          .logout().logoutSuccessUrl(&quot;/login&quot;).permitAll()
          .and()
          .rememberMe().key(token).tokenValiditySeconds(validity)
          .userDetailsService(service)
          .and()
          .csrf().disable();
    }
  
    public AuthenticationFailureHandler authenticationFailureHandler() {
      return new CustomAuthenticationFailureHandler();
    }
  
    public AuthenticationSuccessHandler authenticationSuccessHandler() {
      SavedRequestAwareAuthenticationSuccessHandler handler = new SavedRequestAwareAuthenticationSuccessHandler();
      handler.setTargetUrlParameter(&quot;redirect&quot;);
  
      return handler;
    }
  }
  </code></pre>
  <p>But when I try to navigate to any URL without being authenticated such as <a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080/some-protected-url</a> I would expect to be redirected to <a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080/login?redirect=some-protected-url</a> but the <code>redirect</code> parameter doesn't get appended to the URL.</p>
  <p>What's missing?</p>