【问题标题】:Spring Security with CAS skips session fixation protection带有 CAS 的 Spring Security 跳过会话固定保护
【发布时间】:2013-01-09 16:32:55
【问题描述】:

我有一个使用 spring security 和 CAS(spring 3.0.5,cas 3.4.5)的应用程序,但是当我登录时,会话 ID 没有改变。

当我登录CasAuthenticationFilter 执行身份验证时,如果身份验证成功,它不会继续过滤器链,而是在SecurityContextHolder 上设置身份验证并调用successHandler。这将重定向到我请求的需要身份验证的原始 URL。 SessionManagementFilter 永远不会调用会话策略来创建新会话。

似乎CasAuthenticationFilter 扩展的AbstractAuthenticationFilter 有自己的会话策略,但默认为NullAuthenticatedSessionStrategy,这很容易受到会话固定的影响。问题是为什么默认策略容易受到攻击,当 spring claims to prevent session fixation by default 时?

解决此问题的最佳解决方案是什么?

【问题讨论】:

  • 嗨,你说的是CAS 服务器中的CasAuthenticationFilter,它定义在securityContext.xml 或spring-security cas/core 插件中的那个

标签: java spring-security cas


【解决方案1】:

会话固定策略仅在您使用命名空间时自动设置。如果您使用的是显式过滤器,那么您可以自己将SessionFixationProtectionStrategy 注入过滤器。或者,如果您的应用程序中有一个明显的身份验证后起点,您可以在那里重新创建会话。

由于历史原因,默认情况下可能未设置会话固定版本,因为过滤器早于会话身份验证策略的引入,并且通常以保守的方式引入更改。您可以打开一个更改请求,建议默认情况下它可能会更好。

【讨论】:

  • 感谢您的回答。正如您所建议的,我通过将SessionFixationProtectionStrategy 显式注入到我的 cas 过滤器中进行了修复。我建议这是默认完成的。
【解决方案2】:

我遇到了同样的问题。我通过显式注入 SessionFixationProtectionStrategy 解决了这个问题(基于命名空间的配置似乎不适用于我的 CAS 自定义过滤器)。这是我目前的配置:

<bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl"/>

<bean id="sessionControlStrategy" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
    <constructor-arg ref="sessionRegistry"/>
    <property name="maximumSessions" value="2"/>
</bean>

<bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
    <property name="authenticationManager" ref="authenticationManager" />
    <property name="sessionAuthenticationStrategy" ref="sessionControlStrategy"/>
</bean>

【讨论】:

    猜你喜欢
    • 2012-05-25
    • 2011-04-20
    • 2015-09-12
    • 2016-12-05
    • 2017-12-29
    • 2013-12-20
    • 2020-08-31
    • 1970-01-01
    • 2011-02-06
    相关资源
    最近更新 更多