Identityserver4: Claim in sample project not showing in User.Claims

Created on 20 Oct 2017  路  5Comments  路  Source: IdentityServer/IdentityServer4

In the sample project for Hybrid and API Access

The Users have claims for "website", however when I run the project, website does not show up in the claims list. What is missing?

docs question

Most helpful comment

It's because Microsoft does not map all claims by default from the userinfo into the claims principal. You have to say what claims you want included. Here's what they include by default:

https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs#L63

And here's how you'd add "website":

.AddOpenIdConnect("oidc", options =>
{
   // ...
    options.ClaimActions.MapUniqueJsonKey("website", "website");
}

It's unfortunate that they don't map what comes back from userinfo automatically. Also unfortunate that they're missing 2/3 of the standard claim types.

// @tratcher

All 5 comments

@egmfrs Have you made any progress with this?

@nicbavetta nope

It's because Microsoft does not map all claims by default from the userinfo into the claims principal. You have to say what claims you want included. Here's what they include by default:

https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs#L63

And here's how you'd add "website":

.AddOpenIdConnect("oidc", options =>
{
   // ...
    options.ClaimActions.MapUniqueJsonKey("website", "website");
}

It's unfortunate that they don't map what comes back from userinfo automatically. Also unfortunate that they're missing 2/3 of the standard claim types.

// @tratcher

Closing. If you still have issues, feel free to reopen.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cixonline picture cixonline  路  3Comments

garymacpherson picture garymacpherson  路  3Comments

agilenut picture agilenut  路  3Comments

chrisrestall picture chrisrestall  路  3Comments

user1336 picture user1336  路  3Comments