Skip to content
Discussion options

You must be logged in to vote

You can add any claims that you want — each claim is basically a key/value pair. We're doing something like:

public ClaimsPrincipal GetPrincipal()
{
    var identity = new ClaimsIdentity(AuthenticationType);

    if (!string.IsNullOrWhiteSpace(Name))
    {
        identity.AddClaim(new Claim(Person.ID, Id.ToString()));
        identity.AddClaim(new Claim(ClaimTypes.Name, Name));

        if (CompanyId.HasValue)
            identity.AddClaim(new Claim(Person.COMPANY_ID, CompanyId.ToString()));

        if (Roles != null)
        {
            foreach (var item in Roles)
                identity.AddClaim(new Claim(ClaimTypes.Role, item));
        }
    }

    return new ClaimsPrincipal(iden…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jhuerta3
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants