Spring SAML WSO2刷新断言

时间:2017-02-26 18:03:14

标签: spring wso2 saml wso2is spring-saml

我已经使用WSO2配置了Spring SAML应用程序。当用户登录时,他检索有效等于5分钟的断言。但是5分钟过后,没有发生刷新断言。

断言过期后,如何在页面重新加载时调用/saml/sso?也许您知道另一种解决方案吗?一些豆子的特性?

<{1}}中的{p> maxAuthenticationAge无效。

<{1}}中的{p> org.springframework.security.saml.websso.WebSSOProfileConsumerImpl无效。

1 个答案:

答案 0 :(得分:1)

首先,断言不是SessionNotOnOrAfter中的AuthnStatement属性,因此到期时间为null。在这种情况下,我从Conditions属性的NotOnOrAfter元素获得到期时间,恕我直言,它与SessionNotOnOrAfter具有相同的值。

其次,为安全起见,我要确保从到期时间减去1分钟,该断言将永远存在。

解决方法是覆盖自定义SAMLAuthenticationProvider getExpirationDate方法:

protected Date getExpirationDate(SAMLCredential credential) {
    List<AuthnStatement> statementList = credential.getAuthenticationAssertion().getAuthnStatements();
    DateTime expiration = null;
    for (AuthnStatement statement : statementList) {
        DateTime newExpiration = statement.getSessionNotOnOrAfter();
        if (newExpiration != null) {
            if (expiration == null || expiration.isAfter(newExpiration)) {
                expiration = newExpiration;
            }
        }
    }
    if (expiration == null) {
        Conditions conditions = credential.getAuthenticationAssertion().getConditions();
        expiration = conditions.getNotOnOrAfter();
    }
    return expiration != null ? expiration.minusMinutes(1).toDate() : null;
}
相关问题