I have a solution consisting of:
- ASP.NET Core 2.1 running IdentityServer4 on top of ASP.NET Identity Core.
- ASP.NET Core 2.1 Web API set to use the IdentityServer as the authentication provider.
- A React SPA web application using
oidc-client
javascript library.
When I create new users I set some custom claims that are saved in the AspNetUserClaims
table which looks like this:
Then, on my API project, inside a controller I want to get those user claims of the authenticated user.
I was expecting this.User.Claims
to get me those, but instead that's returning the following, which seem to be claims related to the client app, not the user.
How can I access those custom user claims (address, location, tenant_role
) from a controller inside the Web API project?
Bare in mind that the API project doesn't have access to the UserManager
class or anything ASP.NET Identity Core
related.