简体   繁体   中英

SignalR 2 bind to custom userid from claims

According to some posts i decided to try out the binding of the users by custom user id, no the IPrincipal.Identity.Name .

So I've implemented:

public class CustomUserIdProvider : IUserIdProvider
{
    public string GetUserId(IRequest request)
    {
        var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
        string id = identity.Claims.Where(c => c.Type == UserInfoIdClaimType)
                                   .Select(c => c.Value).Single();
        return id;
    }
}

But when this method is called, there are no claims in the identity ...

So i can't retrieve on this moment the claims from there?

Or maybe i should do it differently?

解决的问题,当我在Web配置中执行操作时,似乎我没有正确注册OWIN身份验证!

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