简体   繁体   中英

Thinktecture Identity Server claims

I'm using Thinktecture Identity Server V3 for authentication and having a problem getting the information from HttpContext.Current.User.

I'm using an API to handle calls but when I call HttpContext.Current.User the ID is not avilable only the claims set by Identity server.

Also when I make a call through signalR the hubs HttpContext.Current.User is null and I can't get the users ID or even look at the cliams.

I'm currently using a custom user service hooked into AspNetIdentity and overriding PostAuthenticateLocalAsync and trying to use the user manager to CreateIdentityAsync but this fails.

Is there any way to populate the default claims on login and retrieve the details on a signalr connection and Web API call?

Thanks

Did you end up solving this?

I'm still pretty new to Thinktecture Identity Server, but I'm going to take a stab at this.

There is an option IncludeAllClaimsForUser on the Scope which is set to false by default. Based on what I'm reading, this option will remove the filter when calling the GetProfileAsync() endpoint.

Here's some links on where I found this info:

http://identityserver.github.io/Documentation/docs/configuration/scopesAndClaims.html

https://github.com/IdentityServer/IdentityServer3/issues/621

No I had to park it until I had time to figure it out.

I did use the IncludeAllClaimsForUser property on the scope which would populate the claims. The issue I had was that User.Identity.GetUserId() would always return null as this is now set within the claim "sub".

This was not such a big issue but when I passed through a bearer token on a signalR connection, Current.User is always null and I can't even read the "sub" claim.

Its like the bearer token is not being validated on a signalR connection so I can't get the users details.

Thanks for the help, its much appreciated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM