【发布时间】:2021-01-29 03:50:41
【问题描述】:
我在 .net core 3.1 应用程序中实现了令牌验证,如下所示:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
{
options.Authority = Configuration["AuthorityUrl"];
options.Audience = Configuration["Audience"];
options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "preferred_username"
};
});
我现在的主要问题是安全威胁,我相信如果用户通过 ID 令牌,则身份验证成功通过,这是错误的,因为资源服务器应该只接受访问令牌。这种行为是否正确?如果是,如何将验证限制为仅访问令牌。
【问题讨论】: