我遇到問題。默認情況下,身份驗證後的彈性安全將您重定向到您之前嘗試訪問的受保護頁面。Spring Security。認證後重定向到受保護的頁面
當我實現我自己的成功處理程序
@Component
class MyS: AuthenticationSuccessHandler {
override fun onAuthenticationSuccess(request: HttpServletRequest?, response: HttpServletResponse?, authentication: Authentication?) {
response?.sendRedirect(request?.getHeader(HttpHeaders.REFERER))
}
}
class SecurityConfigTH(@Autowired private val myHandler: MyS) : WebSecurityConfigurerAdapter() {
...
.formLogin()
.loginPage("/en/login")
.successHandler(myHandler)
.permitAll()
}
我不能達到同樣的效果。我嘗試重定向到引用,但在這種情況下引用是/ en /登錄頁面。
基本上是:
- 用戶試圖訪問受保護的URL
/protected
- 重定向用戶到
/login
頁 - 認證之後用戶應重定向到
/protected
再次
如何使用做自定義的成功處理程序?