Open Closed

How can I get more customized claim from "connect/userinfo" #4885


User avatar
0
Shanzhi_Chen created

Could I customize the OIDC webapi output of "connect/userinfo"?

When I call this webapi, It only returns a few user info like below.

{
    "sub": "92af3c6e-0ea8-a0a1-bbeb-3a0a88b4953e",
    "tenantid": null,
    "preferred_username": "admin",
    "family_name": "Casell",
    "given_name": "Ryan",
    "email": "xxx@xxx.com",
    "email_verified": false,
    "phone_number": "5871231234",
    "phone_number_verified": false,
    "role": [
        "admin"
    ]
}

Is it possible to add other customized claims into it? What I want as follow:

{
    "sub": "92af3c6e-0ea8-a0a1-bbeb-3a0a88b4953e",
    "tenantid": null,
    "preferred_username": "admin",
    "family_name": "Casell",
    "given_name": "Ryan",
    "email": "xxx@xxx.com",
    "email_verified": false,
    "phone_number": "5871231234",
    "phone_number_verified": false,
    "role": [
        "admin"
    ]
    

    // Customized User Claims
    "on_hold": true,
    "sales_rep_id": yyc060
    ...
    ...
    ...
}

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Which authserver provider are you using? IdentityServer or Openiddict

  • User Avatar
    0
    Shanzhi_Chen created

    Hi,

    Which authserver provider are you using? IdentityServer or Openiddict

    Openiddict

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You have to override the GetUserInfoClaims method.

    https://github.com/abpframework/abp/blob/dev/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/UserInfoController.cs#L39

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09