NotOnOrAfter 在 SubjectConfirmationData and Conditions 和 SessionNotOnOrAfter

NotOnOrAfter in SubjectConfirmationData and Conditions and SessionNotOnOrAfter

在 SAML2 规范中,断言中有几个地方可以指定生命周期。

它们各自的含义是什么?它们之间有什么关系?

具体来说,当......

每个 NotOnOrAfter 都在 SAML2 core specification 中进行了描述。我在此处包含了我能找到的描述这些属性的部分。

SubjectConfirmationData/@NotOnOrAfter

A time instant at which the subject can no longer be confirmed. The time value is encoded in UTC, as described in Section 1.3.3.

Note that the time period specified by the optional NotBefore and NotOnOrAfter attributes, if present, SHOULD fall within the overall assertion validity period as specified by the element's NotBefore and NotOnOrAfter attributes. If both attributes are present, the value for NotBefore MUST be less than (earlier than) the value for NotOnOrAfter.

条件/@NotOnOrAfter

Specifies the time instant at which the assertion has expired. The time value is encoded in UTC, as described in Section 1.3.3.

The NotBefore and NotOnOrAfter attributes specify time limits on the validity of the assertion within the context of its profile(s) of use. They do not guarantee that the statements in the assertion will be correct or accurate throughout the validity period. The NotBefore attribute specifies the time instant at which the validity interval begins. The NotOnOrAfter attribute specifies the time instant at which the validity interval has ended. If the value for either NotBefore or NotOnOrAfter is omitted, then it is considered unspecified. If the NotBefore attribute is unspecified (and if all other conditions that are supplied evaluate to Valid), then the assertion is Valid with respect to conditions at any time before the time instant specified by the NotOnOrAfter attribute. If the NotOnOrAfter attribute is unspecified (and if all other conditions that are supplied evaluate to Valid), the assertion is Valid with respect to conditions from the time instant specified by the NotBefore attribute with no expiry. If neither attribute is specified (and if any other conditions that are supplied evaluate to Valid), the assertion is Valid with respect to conditions at any time.

If both attributes are present, the value for NotBefore MUST be less than (earlier than) the value for NotOnOrAfter.

AuthnStatement/@SessionNotOnOrAfter

Indicates an upper bound on sessions with the subject derived from the enclosing assertion. The time value is encoded in UTC, as described in Section 1.3.3. There is no required relationship between this attribute and a NotOnOrAfter condition attribute that may be present in the assertion. It's left to profiles to provide specific processing rules for relying parties based on this attribute.

我将这个问题交叉发布到 SAML-dev mailing list 并得到了规范编辑 Scott Cantor 的回答。

  • <SubjectConfirmationData> 中的时间表明断言可以与主题关联多长时间。在通常使用主题确认方法 "bearer" 的 Web SSO 中,这意味着在这段时间内我们可以相信断言适用于提供断言的人。断言可能会在更长的时间内有效,但我们必须在这个时间范围内创建一个会话。 Web SSO Profile 第 4.1.4.3 节对此进行了描述。 <SubjectConfirmationData>的时间必须在<Conditions>.

  • 的区间内
  • <Conditions>中的次数就是整个断言的有效性。在此时间后不应食用。不过,没有什么可以阻止 SP 上的用户会话超过这个时间点。

  • SessionNotOnOrAfter 是完全不同的东西,与断言或主题的生命周期没有直接关系。它是 idp 可以用来控制 SP 会话的长度的参数。请注意,根据 SAML2Core 规范,此参数被定义为应该由 SP 处理,但并非所有 SP 实现都这样做。一个实现的例子是像往常一样的 Shibboleth,它总是会尊重这个参数的出现。使用单点注销时,此参数更为关键,因为它同步 SP 和 Idp 上的会话超时,以确保 SP 不会为 Idp 不再已知的会话发出注销请求。

在我看来,只有 Saml2 规范的作者才能清楚地回答这个问题。我还猜想他们可以写一本 10000 页的书来解释许多 "why" 人们多年来提出的关于规范的问题。无论如何,根据我有限的知识和我经历过的用例,我对这些属性的解释是:

我们来看一个例子:

  1. SSO:SP 从 IdP 接收断言并让用户登录。
  2. Bootstrap 令牌:SP 将断言保存为 bootstrap 令牌供以后使用。
  3. SP 使用 bootstrap 令牌来交换 ActAs 令牌,以便它可以用于访问另一个 Web 服务。它还将缓存令牌以供进一步使用,以避免必须经常交换新令牌,只要该令牌仍然有效。

对于 (1),当且仅当 SubjectConfirmationData.NotOnOrAfter 和 Conditions.NotOnOrAfter 都有效时,断言才有效。由于断言有效,SP 将为用户创建一个登录会话。会话应持续多长时间由 SessionNotOnOrAfter 值指定。

3个怎么样?我会说当 Conditions.NotOnOrAfter 仍然有效时,令牌被认为是有效的。根据 Scott Cantor 的说法:"Processing rules are specific to profiles and the context of use." 来源:https://lists.internet2.edu/sympa/arc/mace-opensaml-users/2011-05/msg00007.html 在那个 link 中,他们还讨论了主题和条件的生命周期,其中条件的生命周期通常比主题的生命周期长。