【发布时间】:2016-04-26 12:02:15
【问题描述】:
回答这个问题securitycontextholder-session-or-request-bound。 我正在使用此示例how-to-customAuthenticationManager 实现 CustomAuthenticationManager。事实证明,我的用户体验得到了 Accross Session。
例如,用户 A 与 Web App 交互,有时在访问配置文件时,用户 A 可以获取用户 B 的配置文件(这是因为应用程序正在从 SecurityContextHolder 的主体检索 UserProfileLoggedIn 并访问数据库),同时用户 B 已登录,但可能无法访问个人资料。
我想知道这是 SecurityContextHolder 泄漏吗?我知道 SecurityContextHolder 只是将 HttpSession 实现为包含 userDetails 等的容器的一种方式。
现在,在遇到问题后,我将 customAuthenticationManager 更改为 customAuthenticationProvider。有关更多信息,用户在中午大约有 100-500 个并发用户。
有关更多信息,我正在我的@Service 类中实现 SecurityContextHolder,以便其他团队成员可以轻松获得
@Service
public MyServiceImpl implement MyServiceInterface{
public UserDetail findUser(){
return (UserDetail) SecurityContextHolder.getContext().
getAuthentication().getPrincipal();
}
}
【问题讨论】:
-
在挣扎了几个小时后,并实现了单例样式以从 Controller 获取 SecurityContextHolder 并传递给 Service,但我仍然遇到 SecurityContextHolder 泄漏问题。我仍然不知道可能是什么问题......
标签: java spring spring-security