【发布时间】:2020-11-26 22:28:19
【问题描述】:
我在下面有一个添加新声明的代码
public ActionResult AddClaim()
{
try
{
var user = User;
var userIdentity = user.Identities.First();
userIdentity.AddClaim(new Claim("myCustomClaim", "value of claim"));
return View("Secure");
}
catch (Exception ex)
{
throw ex;
}
}
使用 AddClaim() 函数成功添加了声明。
但是,当我解密 jwt.io 中的 id_token 时,我最近添加的声明未包含在有效负载中。我试过调用 HttpContext.SigninAsync() 但它什么也没做。
我的目标是在 JWT 令牌负载中添加自定义声明。我该怎么办?
【问题讨论】:
标签: c# asp.net-mvc jwt token claims