Spring security Saml - SP 和 IDP 的时间差

Posted

技术标签:

【中文标题】Spring security Saml - SP 和 IDP 的时间差【英文标题】:Spring security Saml - Time difference between SP and IDP 【发布时间】:2014-10-28 04:00:25 【问题描述】:

我正在寻找一种方法来增加我的 saml 消息的过期时间。我将 Spring Security 与 SAML 1.0.0-RC2 一起使用。

此时,如果服务器**时间相差太大,例如5 分钟,我收到以下错误:

HTTP Status 401 - Authentication Failed:Error validating SAML message: SAML response is not valid; nested exception is org.opensaml.common.SAMLException: SAML response is not valid

我想将过期时间设置为 10 分钟,以防止出现这些错误。我一直在看文档,但我不明白如何更改过期时间。如果我查看Configuration authentication object 部分,可以更改过期时间,但我无法理解这个想法。

有人可以帮帮我吗?

** 我的服务器 (SP) 和客户的服务器(IDP,很可能是安装了 ADFS 的服务器)。

【问题讨论】:

您将收到的其他指示 SP 和 IdP 之间的 responseSkew / 时间不匹配的错误消息是:org.opensaml.common.SAMLException:响应问题时间太旧或未来日期, skew 60,时间 2015-08-27T12:40:28.284Z,或 LogoutResponse 中的响应发布时间太旧或未来日期。 【参考方案1】:

在 Stefan 的 anwser 之后,我知道该去哪里找了!实际上文档确实描述了这件事,我只是没有拿起它:10.3 Validity intervals。为 Stefan 指出 responseSkew 属性干杯!

只需将属性 responseSkew 添加到 WebSSOProfileConsumerImpl 和 SingleLogoutProfileImpl bean:

<bean id="webSSOprofileConsumer" class="org.springframework.security.saml.websso.WebSSOProfileConsumerImpl">
    <property name="responseSkew" value="600"/> <!-- 10 minutes -->
</bean>

<bean id="logoutprofile" class="org.springframework.security.saml.websso.SingleLogoutProfileImpl">
    <property name="responseSkew" value="600"/> <!-- 10 minutes -->
</bean>

【讨论】:

@jacob,我正在使用 grails,即使我将 responseSkew 指定为 60000,我仍然会收到此错误!有什么帮助吗???在 grails 中我没有 bean 声明,所以一切都是从配置文件连接的。所以设置很好..但我仍然遇到同样的异常 @artapart:抱歉,我从来没有在生活中使用过 Grails,所以我不知道。只需将此作为一个新的 *** 问题提出,Grails 社区就可以为您提供帮助! 您是否还必须禁用 CSRF ? &lt;security:csrf disabled="true"/&gt; 不,您可以保留当前的 ​​CSRF 设置。无需更改! @JacobvanLingen 嗨,我面临同样的问题。尝试您提供的 bean 时,出现错误:Error creating bean with name 'webSSOprofileConsumer'. No qualifying bean of type 'org.springframework.security.saml.metadata.MetadataManager' available。你有什么建议吗?谢谢。【参考方案2】:

看起来允许的时差是硬编码的。

See this source file 查看常量 responseSkew。默认值为 60 秒。

我认为您最好的选择是尝试在服务器上设置相同的时间。

【讨论】:

非常感谢,您确实给了我寻找问题的方向。但该值不是硬编码,默认为 60 秒! 正确,对不起【参考方案3】:

我知道,已经选择了答案,但我正在分享我为使用 Grails 3、spring security core、SAML 2.0 的任何人找到的解决方案。

我必须设置maxAssertionTimeresponseSkew 值,WebSSOProfileConsumerImpl 才能从 IDP 获得响应。

【讨论】:

以上是关于Spring security Saml - SP 和 IDP 的时间差的主要内容,如果未能解决你的问题,请参考以下文章