WSO2 id_token 缺少声明
WSO2 id_token with missing claims
在我的要求中,我需要获得"auth_time"和"acr" openid claim。在我的 id 令牌上只能得到这些声明:
amr、iss、exp、iat、nonce、c_hash、aud 和 at_hash
如何在令牌响应中添加这些声明?
我使用 openid-client 节点 js 库添加 scope="openid"
您可能希望在服务提供商中将这些声明添加为 Requested Claims
。
https://docs.wso2.com/display/IS580/Configuring+Claims+for+a+Service+Provider
根据 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,您可以在授权流程中发送一个带有max_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 身份服务器一起使用。通过这种方式,身份提供者可以在用户身份验证流程中实施额外的保证。您可以 select 来自身份验证脚本的 acr。然后身份服务器将在 id_token 响应中发送 selected acr。您可以按照此 document 在身份服务器中使用 ACR 以及如何配置以在 id_token 中获取 acr 值。
在我的要求中,我需要获得"auth_time"和"acr" openid claim。在我的 id 令牌上只能得到这些声明: amr、iss、exp、iat、nonce、c_hash、aud 和 at_hash
如何在令牌响应中添加这些声明? 我使用 openid-client 节点 js 库添加 scope="openid"
您可能希望在服务提供商中将这些声明添加为 Requested Claims
。
https://docs.wso2.com/display/IS580/Configuring+Claims+for+a+Service+Provider
根据 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,您可以在授权流程中发送一个带有max_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 身份服务器一起使用。通过这种方式,身份提供者可以在用户身份验证流程中实施额外的保证。您可以 select 来自身份验证脚本的 acr。然后身份服务器将在 id_token 响应中发送 selected acr。您可以按照此 document 在身份服务器中使用 ACR 以及如何配置以在 id_token 中获取 acr 值。