我们使用 ADFS 作为 IDP,我们的应用程序充当 SP。下面是一个示例 Auth 响应
<?xml version="1.0" encoding="UTF-8"?>
<Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_82062d3d-897f-473e-90ad-0bb351d63b22" IssueInstant="2015-04-29T20:39:17.240Z" Version="2.0">
<Issuer>http://adfs/services/trust</Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ds:Reference URI="#_82062d3d-897f-473e-90ad-0bb351d63b22">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue />
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data>
<ds:X509Certificate>certificate..... </ds:X509Certificate>
</ds:X509Data>
</KeyInfo>
</ds:Signature>
<Subject>
<NameID>username</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<SubjectConfirmationData InResponseTo="923ki0eg8h7g7y2243fi9jbdd1977j9" NotOnOrAfter="2015-04-29T20:44:17.240Z" Recipient="https://localhost/saml/SSO" />
</SubjectConfirmation>
</Subject>
<Conditions NotBefore="2015-04-29T20:39:17.240Z" NotOnOrAfter="2015-04-29T21:39:17.240Z">
<AudienceRestriction>
<Audience>https://localhost/saml/metadata</Audience>
</AudienceRestriction>
</Conditions>
<AuthnStatement AuthnInstant="2015-04-29T20:39:17.162Z" SessionIndex="_92062g3d-897f-473e-90ad-0aa351d63b22">
<AuthnContext>
<AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</AuthnContextClassRef>
</AuthnContext>
</AuthnStatement>
</Assertion>
我面临的问题可以分为两种情况:
在 1 小时的空闲时间后,我在本地注销了用户。服务器 session 到期的默认值为 30 分钟。如果用户正在积极处理某事,我有我的代码每 10 分钟发送一次心跳 ping。现在,问题是当用户在 session 过期 1 小时后尝试登录时,我得到以下异常
Caused by: org.springframework.security.authentication.CredentialsExpiredException: Authentication statement is too old to be used with value 2015-05-28T17:41:52.648Z at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAuthenticationStatement(WebSSOProfileConsumerImpl.java:538) at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAssertion(WebSSOProfileConsumerImpl.java:306) at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:214) ... 77 more
这里的问题是.. 为什么我们的应用程序会尝试验证 token 颁发时间的实例?它可以随时授予..
我不断收到 SAMLException 消息“本地实体不是至少一个 AudienceRestriction 中断言的预期受众”。轨迹如下
Caused by: org.opensaml.common.SAMLException: Local entity is not the intended audience of the assertion in at least one AudienceRestriction at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAudience(WebSSOProfileConsumerImpl.java:506) at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAssertionConditions(WebSSOProfileConsumerImpl.java:458) at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAssertion(WebSSOProfileConsumerImpl.java:303) at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:214) ... 77 more
我不明白为什么会发生此异常。
请帮助我理解这个概念。
谢谢!
最佳答案
您的 IDP 正在重用用户之前已通过身份验证的信息(在 Authentication Instant 标识的时间),并且 Spring SAML 默认配置为如果用户在 7200 秒前通过身份验证,则不允许用户登录。
这是一种安全措施 - 如果很久以前计算机已经对用户进行了身份验证,则很难保证仍然是同一个人操作计算机。 Spring SAML 为您提供了一些方法来配置可接受的安全级别 - 例如通过使其可配置。
您可以通过在 WebSSOProfileConsumerImpl
bean 上设置属性 maxAuthenticationAge
来增加此值。
只有当断言包含 Audience 元素并且它们都不匹配您的应用程序的实体 ID 时,才会发生受众错误。我认为您问题中的响应不是触发此错误的原因吗?
关于spring - IDP 发起的 SAML 登录错误 - 身份验证语句太旧,无法与值一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30528636/