0
我使用基於令牌的身份驗證,我是新主題。我有這個問題:在 AuthenticationTicket(claimsIdentity,properties)
中添加聲明和添加屬性之間有什麼區別。所以在這個例子中:基於令牌的身份驗證票據部分
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
identity.AddClaim(new Claim("sub", context.UserName));
identity.AddClaim(new Claim("role", "user"));
var props = new AuthenticationProperties(new Dictionary<string, string>
{
{
"as:client_id", (context.ClientId == null) ? string.Empty : context.ClientId
},
{
"userName", context.UserName
}
});
var ticket =new AuthenticationTicket(identity, props);
在聲明和票據屬性中添加userName有什麼區別?