【问题标题】:Spring Security Preauthorization ReauthenticationSpring Security 预授权重认证
【发布时间】:2014-11-04 12:06:31
【问题描述】:

使用 Spring Security 3.2.5 和 Spring 4.0.6。 Spring Security 配置为使用 http 标头进行预身份验证。

Spring Security 可以正确抓取头部、查找用户并从数据库中获取身份验证角色。

问题是当用户注销并以新用户身份登录时,spring security没有检测到更改的header,仍然返回之前登录的用户。

1 - 通过外部应用程序 (siteminder) 以用户#1 身份登录

2 - spring security 正确报告用户#1 已登录

3 - 在应用程序之外,退出站点管理器

4 - 通过站点管理员以用户#2 身份登录

5 - 在 web 应用程序中,当 siteminder 为用户#2 提供标头信息时,spring security 现在会错误地报告用户#1 登录

在 spring-security.xml 中,我尝试为 spring security 添加一个指令以不缓存用户,但它在应用程序中出现异常。

<security:http create-session="stateless" />

ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Wed Sep 10 11:57:10 MDT 2014]; root of context hierarchy

Configuration problem: No AuthenticationEntryPoint could be established. Please make sure you have a login mechanism configured through the namespace (such as form-login) or specify a custom AuthenticationEntryPoint with the 'entry-point-ref' attribute

如何配置spring security在pre-authentication header改变时重新授权?

谢谢!

【问题讨论】:

    标签: java spring spring-security


    【解决方案1】:

    您应该能够通过将预授权过滤器上的 checkForPrincipalChanges 属性设置为 true 来实现。

    来自 API 文档:

    将在每个请求上检查预身份验证的主体,并与当前身份验证对象的名称进行比较。如果检测到更改,将重新对用户进行身份验证。

    您可能还想设置invalidateSessionOnPrincipalChange 属性(如果您希望忘记上一个会话)。

    【讨论】:

    • 做到了!没有读过手册,我觉得很菜鸟。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2014-04-02
    • 2018-02-03
    • 2012-08-15
    • 2011-11-10
    • 2016-08-20
    • 2016-02-03
    • 2021-05-28
    • 2013-05-31
    相关资源
    最近更新 更多