Answers for "get claims from jwt token middleware .net framework"

C#
0

get claims from jwt token middleware .net framework

OnUserInformationReceived = context =>
{
    var admins = new string[]
    {
        "[email protected]",
        "{your email address here}"
    };

    var additionalClaims = new List<Claim>();
    if (admins.Contains(context.Principal.FindFirstValue("email")))
    {
        additionalClaims.Add(new Claim("role", "Admin"));
    }

    var newIdentity = new ClaimsIdentity(context.Principal.Identity, additionalClaims, "pwd", "name", "role");
    context.Principal = new ClaimsPrincipal(newIdentity);

    return Task.CompletedTask;
},
Posted by: Guest on August-31-2021

Code answers related to "get claims from jwt token middleware .net framework"

C# Answers by Framework

Browse Popular Code Answers by Language