I added Spring Security Kerberos to my application and I implemented a form login in case the user is not logged in to the domain or the browser does not support SSO. The only problem with this is that after successful login the user is not redirected to the original page, they are instead redirected to the default "/". Below you can find my configuration, what am I missing please?
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.headers().frameOptions().disable()
.and()
.exceptionHandling().accessDeniedPage("/login")
.authenticationEntryPoint(spnegoEntryPoint())
.and()
.authorizeRequests()
.regexMatchers("^\\S*.js|\\S*.css$").permitAll()
.anyRequest().hasAnyAuthority("APP USER")
.and()
.logout()
.permitAll()
.and()
.formLogin().loginPage("login").loginProcessingUrl("/spnego_login").permitAll()
.and()
.rememberMe().rememberMeServices(rememberMeServices()).key(KEY)
.and()
.addFilterBefore(
spnegoAuthenticationProcessingFilter(authenticationManagerBean()),
BasicAuthenticationFilter.class)
.csrf().disable();
}
Login Page
<form class="form-signin" action="/spnego_login" method="post" accept-charset=utf-8>
<h2 class="form-signin-heading">Please Log In Manually</h2>
<label for="inputEmail" class="sr-only">Username</label>
<input type="text" id="inputEmail" class="form-control" placeholder="username" name="username" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" name="password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
UPDATE
I tried using SavedRequestAwareAuthenticationSuccessHandler as recommended but it turns out that the previous URL is not found in the Cache. Therefore, the success handler always defaults.