【发布时间】:2019-06-24 23:25:16
【问题描述】:
我知道 Spring Security 在成功验证时会创建一个名为 SESSION 的 cookie。是否可以在 AuthenticationSuccessHandler 中获取该 cookie 值。
我有以下实现,其中我需要 SESSION cookie 值。我看起来是 HttpServletResponse 的响应标头,但它们有 XSRF-TOKEN 设置 cookie 标头,
@Component
public class MyAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
@Override
public void onAuthenticationSuccess(
HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException {
// GET SESSION, COOKIE VALUE HERE
}
}
你能帮忙吗?
【问题讨论】:
-
HttpServletResponse的set-cookie header的值是多少?是{'Set-Cookie': 'SESSION=xxxx-xxxx-xxxx-xxxxxxx;的形式吗?路径=/; HttpOnly'} ?
标签: spring spring-boot spring-security spring-session