ASP .NET核心,将JWT存储在cookie中
我听到了它是存储JWT的最安全方法之一。我的问题是。如何将其保存在cookie中?
这是parterup.cs中的配置中的功能
services.AddControllers();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<ITokenService, TokenService>();
IdentityModelEventSource.ShowPII = true;
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = Configuration["Jwt:Issuer"],
ValidAudience = Configuration["Jwt:Issuer"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
};
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传递给AddJwtBearer的选项对象包含其自身的事件属性,该属性使您可以自定义过程的各个部分。您需要使用MESSAGERECEEDEVER事件进行相同的
Options object being passed in to AddJwtBearer contains an Events property of its own, which allows you to customize various parts of the process. You need to use MessageReceived Event for the same
Using HTTP cookie with asp.net core