响应的SAML2异常inresponsetofield与发送的消息不对应

时间:2019-02-15 08:43:49

标签: java saml-2.0 spring-saml

我们使用'spring-security-saml2-core:1.0.4.RELEASE'实现SSO。但是在一种情况下,我们会收到此错误:“响应的InResponseToField与发送的消息a3b529hi99h247cj2b0670ja8a5fdcf不对应”。案例步骤如下:

1。打开我们的网站登录页面

2。什么也不做,请等待30分钟,直到此http会话超时

3。输入用户名和密码,然后单击登录按钮

4。错误发生,“响应的InResponseToField与发送的消息不对应”

我在saml核心代码WebSSOProfileConsumerImpl.java中发现了此错误

    // Verify response to field if present, set request if correct
    SAMLMessageStorage messageStorage = context.getMessageStorage();
    if (messageStorage != null && response.getInResponseTo() != null) {
        XMLObject xmlObject = messageStorage.retrieveMessage(response.getInResponseTo());
        if (xmlObject == null) {
            throw new SAMLException("InResponseToField of the Response doesn't correspond to sent message " + response.getInResponseTo());
        } else if (xmlObject instanceof AuthnRequest) {
            request = (AuthnRequest) xmlObject;
        } else {
            throw new SAMLException("Sent request was of different type than the expected AuthnRequest " + response.getInResponseTo());
        }
    }

似乎saml将通过'messageStorage.retrieveMessage(response.getInResponseTo())验证响应 我发现默认的messageStorage是基于HttpSession的HttpSessionStorage。

所以我认为当会话超时时,“ messageStorage.retrieveMessage”将返回null。

所以我通过配置'server.servlet.session.timeout = 60m'延长了会话超时。但是,它不起作用。

30分钟而不是60分钟后仍会发生错误。我希望它在60分钟内不会发生错误。 有人可以帮助我吗?非常感谢!

0 个答案:

没有答案
相关问题