Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

ClaimTypes value is different than what it seems

$
0
0

Hi,

I am generating a jwt token and giving some claims like 

var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Issuer = "Issuer",
                    Audience = "Audience",
                    Subject = new ClaimsIdentity(new Claim[]
                    {
                        new Claim(ClaimTypes.Sid, "1"),
                        new Claim(ClaimTypes.Name, "test user"),
                        new Claim(ClaimTypes.Email, "test@gmail.com"),
                        new Claim(ClaimTypes.Role, "User")
                    }),
                    Expires = DateTime.UtcNow.AddMinutes(15),
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.ASCII.GetBytes("secret key")),
                                                                    SecurityAlgorithms.HmacSha256Signature)
                };

                var tokenHandler = new JwtSecurityTokenHandler();
                var token = tokenHandler.CreateToken(tokenDescriptor);

But when I inspect the token on jwt.io site then claim property names are 

"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/sid": "1","unique_name": "test user","email": "test@gmail.com","role": "User","nbf": 1602438310,"exp": 1602438430,"iat": 1602438310,"iss": "issuer","aud": "audience"
}

While getting claim from token using same ClaimTypes.Email then it throws null reference error. Also while value for ClaimTypes.Email ishttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress then why it is showing simply "email" in jwt.io while the name for "Sid" claim seems correctly?

Thanks 


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>