SAML 2.0 是否允许向 IdP 发送 SP 数据?

Does SAML 2.0 allow to send SP data to IdP?

我正在阅读 SAML 规范并尝试使用 KeycloakShibboleth IdP,但我不确定如何在 SP 启动的登录中实现一项功能。

我有一项服务,过去通常在其登录页面上显示 SP 状态信息(例如应用程序版本、状态)。切换到使用 IdP 登录页面后,我想继续在 IdP 的登录页面上显示此类每个 SP 的附加信息。我对数据交换感兴趣,而不是对登录页面本身进行模板化。

SAML 2.0 规范是否允许为了登录目的向 IdP 发送任意数据?如果不是,还有哪些其他选项可用于使用 SP 生成的数据装饰 IdP 登录页面?

SP 唯一可以发送给 IdP 的是 Subject(参见规范的 lines 585-589)。

有点。从 SP 到 IdP 的身份验证请求允许有 "custom" 扩展(Extensions 父元素),扩展的内容由您决定。来自规范:

[Optional] This extension point contains optional protocol message extension elements that are agreed on between the communicating parties. No extension schema is required in order to make use of this extension point, and even if one is provided, the lax validation setting does not impose a requirement for the extension to be valid. SAML extension elements MUST be namespace-qualified in a non-SAML-defined namespace.

如果您正在编写自己的 IdP,您当然可以使用 Extensions 并随心所欲地使用它。 "Standard" (commercial/OSS) IdP 不知道如何处理您的扩展。看看 Shibboleth 或 Keycloak 库是否解析扩展元素并为您提供内容将是一个有趣的测试。

另一种更标准的可能性是使用 RelayState。这是一种 spec-compliant 传递一些 provider-specific 状态信息的方式,包括。从 SP 到 IdP:

3.1.1 Use of RelayState Some bindings define a "RelayState" mechanism for preserving and conveying state information. When such a mechanism is used in conveying a request message as the initial step of a SAML protocol, it places requirements on the selection and use of the binding subsequently used to convey the response. Namely, if a SAML request message is accompanied by RelayState data, then the SAML responder MUST return its SAML protocol response using a binding that also supports a RelayState mechanism, and it MUST place the exact RelayState data it received with the request into the corresponding RelayState parameter in the response.

同样,所有 IdP 或下层库都将解析 RelayState,但他们如何从那里处理它取决于他们对规范的阅读。一方面,规范要求 RelayState 为 80 字节,并通过签名或 "other means" 进行完整性保护。 IdP 和 SP 经常忽略此限制。

您要在 IdP 登录页面上显示哪些 SP-specific 信息?