Sum*_*wat 7 authentication jwt asp.net-core-webapi asp.net-core-1.1
我已经实现了 JWT Bearer 令牌基础身份验证和授权。我正在使用下面的代码来销毁 JWT 令牌或注销当前用户,但它不起作用。
//var claim = _httpContextAccessor.HttpContext.User.Claims;
// var users = await _userManager.FindByNameAsync(_httpContextAccessor.HttpContext.User.Identity.Name);
// var identity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity;
// foreach (var item in claim)
// {
// identity.RemoveClaim(item);
// }
await _signInManager.SignOutAsync();
Run Code Online (Sandbox Code Playgroud)
在用户注销期间无法取消/撤销 JWT 令牌,这并不简单,但有一个解决方法。您可以尝试按照以下步骤操作:
我还粘贴了下面两个我认为非常有帮助的链接:
| 归档时间: |
|
| 查看次数: |
15774 次 |
| 最近记录: |