gpt4 book ai didi

wso2 身份服务器 oauth userinfo 只返回 sub

转载 作者:行者123 更新时间:2023-12-05 08:56:23 26 4
gpt4 key购买 nike

我已经在 wso2 身份服务器中设置了 SP,并且能够使用 playground 在 auth2 中获取 access_token。引用:https://docs.wso2.com/display/IS510/OAuth+2.0+with+WSO2+Playground

然后我像这样访问了 userinfo 端点:

curl -k -H "Authorization: Bearer 603b0a91-0354-3b64-90e9-0eb1fdd8f162" https://localhost:9443/oauth2/userinfo?schema=openid

我总是得到 JSON:

{"sub":"admin@carbon.super"}

但默认情况下还应该有其他属性,如名字、姓氏、电子邮件...等。如何配置服务器以返回所有这些信息?

P.S 试过 IS 5.1 和 5.2

最佳答案

似乎通过 UserInfo 端点为范围 openid 返回声明的逻辑只是返回在 OIDC 文件中配置的声明和在 SP 级别配置的声明的交集。基于这个逻辑,我能够通过以下步骤解决这个问题。

  1. WSO2 是默认的 openid 范围绑定(bind)到一组预定义的声明。您可以使用/_system/config/oidc 中的 oidc 文件对其进行配置,如下面的屏幕截图所示。 enter image description here
  2. 比如说。如果您想默认使用 openId 范围获取用户的电子邮件地址,它应该带有 userInfo 端点,因为默认设置了“电子邮件”方案(见上面的屏幕截图)
  3. 根据 default claims

查看电子邮件声明的 Claim UriMapped Attribute 的值 http://wso2.org/oidc/claim方言 enter image description here

  1. 现在你需要添加正确的http://wso2.org/claims声明映射到 http://wso2.org/oidc/claim 中的电子邮件声明到 SP 配置。您可以使用相同的映射属性 找到它。即对于此示例,http://wso2.org/claims 中有相同的“电子邮件”声明。 . enter image description here
  2. http://wso2.org/claims 中添加“电子邮件”声明到 SP 配置 enter image description here

现在请求

curl -k -H "Authorization: Bearer 8b2805a7-5b74-33ee-84df-2a8c53a16f6c" https://localhost:9443/oauth2/userinfo?schema=openid

你会得到回应

{"sub":"admin@carbon.super","email":"admin@wso2.com"}

关于wso2 身份服务器 oauth userinfo 只返回 sub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41281292/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com