【发布时间】:2018-11-19 18:35:47
【问题描述】:
我想将 JWT 存储在 cookie 中,并使用它来验证用户或 HTTP 标头中的不记名令牌。
目前我只使用 HTTP-Auth 标头并且它正在工作。
我尝试像这样使用身份 Cookie 和 JwT:
[Authorize] //Cookie auth?!
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class ValuesController : ControllerBase
Startup.cs:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(...)
...
services.AddIdentity<ApplicationUser, IdentityRole>()
我还尝试在AddAuthentication() 中添加不同的方案。它不工作。
我的问题是如何同时为动作/控制器激活 JWT 和 ASP.NET 身份验证。
【问题讨论】:
-
问题是什么?你被否决了,因为正如它目前所写的那样,很难准确地说出你在问什么。请澄清您的具体问题或添加其他详细信息以准确突出您的需求
标签: c# asp.net-core asp.net-core-webapi