【发布时间】:2018-04-24 23:48:04
【问题描述】:
在 ASPNetCore 中命名声明的基于标准的方法是什么?
例如,我正在使用以下内容创建 JWT,但我想从中取出字符串。
var claims = new[]
{
new Claim("UserName", user.UserName),
new Claim("UserId", user.Id),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
new Claim("AppUserId", appUser.Id.ToString()),
new Claim("TenantId", user.TenantId.ToString())
};
似乎有两个不同的 dotnetcore 类:
`System.IdentityModel.Tokens.Jwt.JwtRegisteredClaimNames`
`System.Security.Claims.ClaimTypes`
我应该使用哪些?
JwtRegisteredClaimName 如下所示:public const string Sub = "sub";
而 ClaimTypes 看起来像这样: public const string Name = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name";
我不知道什么时候不同。为什么是第二种情况的url?
【问题讨论】:
标签: asp.net-core asp.net-identity claims-based-identity