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

Pra*_*hal 2 wso2 wso2is

我在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
Run Code Online (Sandbox Code Playgroud)

我总是得到JSON:

{"sub":"admin@carbon.super"}
Run Code Online (Sandbox Code Playgroud)

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

PS尝试了IS 5.1和5.2

Pra*_*hal 7

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

  1. WSO2 IS默认的openid范围绑定到预定义的声明集.您可以使用/ _system/config/oidc中的oidc文件进行配置,如下面的屏幕截图所示. 在此输入图像描述
  2. 比如说.如果你想默认使用openId范围获取用户的电子邮件地址,它应该带有userInfo端点,因为默认设置了"email"方案(见上面的截图)
  3. 根据默认声明

http://wso2.org/oidc/claim方言 查看电子邮件索赔的Claim UriMapped Attribute的值在此输入图像描述

  1. 现在,您需要将映射到http://wso2.org/oidc/claim中的电子邮件声明的正确http://wso2.org/claims声明添加到SP配置中.您可以使用相同的映射属性找到它.即,对于此示例,在http://wso2.org/claims中存在相同的"电子邮件"声明. 在此输入图像描述
  2. http://wso2.org/claims中的"电子邮件"声明添加到SP配置中 在此输入图像描述

现在请求

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

你会得到回应

{"sub":"admin@carbon.super","email":"admin@wso2.com"}
Run Code Online (Sandbox Code Playgroud)