私はアプリケーションにSpring Security Kerberosを追加しました。ユーザーがドメインにログインしていないかブラウザがSSOをサポートしていない場合にフォームのログインを実装しました。この問題の唯一の問題は、ログインに成功した後、ユーザーは元のページにリダイレクトされず、代わりにデフォルトの「/」にリダイレクトされることです。私の設定を見つけることができます、私は何を逃してください?春のセキュリティはいつでもログイン後に "/"にリダイレクト
@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();
}
ログインページ
<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 推奨されているように私はSavedRequestAwareAuthenticationSuccessHandler
を使用してみましたが、それは以前のURLがキャッシュ内に見つからないことが判明。したがって、成功ハンドラは常にデフォルトになります。
[ログインが成功した後に前のページにリダイレクトされる]の可能性のある重複の可能な複製(http://stackoverflow.com/questions/14573654/spring-security-redirect-to-previous-page-after-succesful-login) – OrangeDog