欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

wso2~自定义id_token,自定义id_toke

来源: javaer 分享于  点击 14409 次 点评:163

wso2~自定义id_token,自定义id_toke


  • https://medium.com/@vinula9/scope-allowlisting-whitelisting-in-wso2-api-manager-for-generating-access-tokens-per-device-or-9d16746c048b
  • https://nipunaupeksha.medium.com/scopes-and-claim-management-in-wso2-is-dc845c119b84

id_token

它是一个jwt token,用来存储用户基本信息,默认走的是openid的scope,里面默认有sub这个字段,用来表示用户的id。

自定义id_token和用户信息响应

这块需要通过配置sp的claim来实现,而不是IDP的claim,这块需要特别注意

scope配置

  • email
  • nickname
  • username
  • lastname
  • givenname

claim的配置

scope里的元素由claim组成

openid下面的claim列表

对某个claim里的元素进行编辑

具体服务SP认证配置

现在我们选择(Service Providers → List →你的应用),然后添加一个claim

  • http://wso2.org/claims/emailaddress
  • http://wso2.org/claims/lastname
  • http://wso2.org/claims/givenname
  • http://wso2.org/claims/username
  • http://wso2.org/claims/nickname

获取用户信息

curl --location 'https://localhost:9443/oauth2/userinfo?schema=openid' \
--header 'Authorization: Bearer 08eca470-ae4f-39dc-9d6a-7dd1ba75514b'

响应

{
    "nickname": "test.zhang12",
    "sub": "347c9e9e-076c-45e3-be74-c482fffcc6e5",
    "email": "test@sina.com"
}

解析id_token

在获取token之后,我们可以解析id_token,这时自定义的claim将在这里出现,如图

作者:仓储大叔,张占岭,
荣誉:微软MVP
QQ:853066980

支付宝扫一扫,为大叔打赏!

相关栏目:

用户点评