缺少声明的 WSO2 id_token

标签 wso2 wso2-identity-server

在我的要求中,我需要获取“auth_time”和“acr”openid 声明。在我的 id token 上只能得到这些声明: amr、iss、exp、iat、nonce、c_hash、aud 和 at_hash

如何在 token 响应中添加这些声明? 我使用 openid-client 节点 js 库添加范围=“openid”

最佳答案

根据OpenID Connect spec 、 auth_time 和 acr 是可选声明。因此,默认情况下,WSO2 身份服务器不会在 id_token 中发送这些声明。

<强>1。 auth_time:

根据规范,

auth_time: Time when the End-User authentication occurred. Its value is a JSON number representing the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date/time. When a max_age request is made or when auth_time is requested as an Essential Claim, then this Claim is REQUIRED; otherwise, its inclusion is OPTIONAL.

身份服务器遵守规范,您可以选择获取 auth_time 作为 id_token 中的声明。

选项1:

要获取 auth_time,您可以在授权流程中发送带有 ma​​x_time 作为参数的请求。下面给出了示例请求

https://localhost:9443/oauth2/authorize?response_type=code&scope=openid&max_age=12345&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fplayground2%2Foauth2client&client_id=KmerETRbZx2ErGhCqRfv4xhxeSAa

选项2:

此外,您可以请求 auth_time 作为请求中的基本声明。 您必须将声明作为请求参数传递,并将 auth_time 作为基本声明发送。

{"id_token":{"auth_time":{"essential":true}}}

您必须进行 url 编码,并将其作为值传递给授权端点的 claims 请求参数。下面给出了示例请求。

https://localhost:9443/oauth2/authorize?response_type=code&scope=openid&&claims=%7B%22id_token%22%3A%7B%22auth_time%22%3A%7B%22essential%22%3Atrue%7&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fplayground2%2Foauth2client&client_id=KmerETRbZx2ErGhCqRfv4xhxeSAa

<强>2。 acr:

acr: OPTIONAL. Authentication Context Class Reference.

要获取 id_token 中的 acr 值,首先需要将 acr_values 作为请求参数与所有 acr 值一起传递。

您可以通过使用自适应身份验证脚本轻松地将 ACR 和 AMR 与 WSO2 Identity Server 结合使用。通过这种方式,身份提供者可以在用户身份验证流程中实现额外的保证。您可以从身份验证脚本中选择 acr。然后身份服务器将在 id_token 响应中发送选定的 acr。您可以关注这个document在身份服务器中使用 ACR 以及如何配置以获取 id_token 中的 acr 值。

关于缺少声明的 WSO2 id_token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59080923/

相关文章:

apache-axis - wso2 esb 不支持的媒体类型

node.js - "TypeError: failed to fetch"用于 Wso2 apim 存储中的 api 调用

node.js - 使用 SSO OIDC 身份验证协议(protocol)从 WSO2 IS 检索 JWT token

java - 当前使用 WSO2 Identity Server API 的示例

java - 如何在 Wso2 身份服务器中获取用户的所有用户配置文件声明

wso2 - 在 WSO2 IS 中添加安全问题

jms - WS02 Websphere MQ 的 JMS 传输

wso2 - 如何为新的 WSO2 keystore 安装 GoDaddy SSL 证书

wso2 - WSO2 ESB 和 WSO2 EI 集成哪一个更好

WSO2 身份服务器 - 限制对 SSO 服务的访问