私はSpring Securityを使用していますが、ログイン中にフレームワークの異常な動作が検出されました。 Spring Security WebAuthenticationDetails
は、HTTPリクエストから取得しているパラメータsessionId
を持っていますが、すべてが良いはずですが、実際にはRESTリクエストによって別のセッションIDが返されます。 HttpSession
をautowireしてからセッションIDを取得すると、私はSpringのようなIDを取得します。だから、1人のユーザーに2つのIDがあるようです。それが正しいか?または私は何かを逃した?Autowiring HttpSessionはHttpServletRequestとは異なるオブジェクトを返します
EDITED:このクラスの意志は、この方法が与える
public class AuthenticationEventListener implements ApplicationListener<AbstractAuthenticationEvent> {
@Autowired
HttpSession httpSession;
@Override
public void onApplicationEvent(AbstractAuthenticationEvent event) {
if (event instanceof AuthenticationSuccessEvent) {
LoggedUser loggedUser = (LoggedUser) event.getAuthentication().getPrincipal();
loggedUser.initSessionParams(event.getAuthentication());
String sessionId = httpSession.getId();
}
}
}
と、いくつかのセッションIDを与え例えば
別の1:
@RequestMapping(value = "/chart")
public Map getTestStatusesChart(HttpServletRequest request) {
String sessionId= request.getSession(false).getId();
return null;
}