在ASP.NET Core 3中更新身份验证cookie 3
在ASP.NET Core 3应用中,我使用没有身份的身份验证cookie。这是用户登录时的代码。
string securityStamp = Guid.NewGuid().ToString();
var userClaims = new List<Claim>()
{
new Claim("id", id_user.ToString()),
new Claim("securityStamp", securityStamp),
}
var grantMyIdentity = new ClaimsIdentity(userClaims, "User Identity");
var userPrincipal = new ClaimsPrincipal(new[] { grantMyIdentity });
await HttpContext.SignInAsync(userPrincipal);
在某个时候,我想在不使用户登录并再次登录的情况下更新cookie的安全stamp。 我该如何为用户透明地做到这一点?
In ASP.net CORE 3 app, I use authentication cookie without Identity. Here is the code when a user log in.
string securityStamp = Guid.NewGuid().ToString();
var userClaims = new List<Claim>()
{
new Claim("id", id_user.ToString()),
new Claim("securityStamp", securityStamp),
}
var grantMyIdentity = new ClaimsIdentity(userClaims, "User Identity");
var userPrincipal = new ClaimsPrincipal(new[] { grantMyIdentity });
await HttpContext.SignInAsync(userPrincipal);
At some point, I would like to update the securityStamp of the cookie without making the user log out and log in again.
How can I do this transparently for the user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论