ASP.NETCore5中,WWW-Authenticate头中的Realm已被删除。
创始人
2024-09-17 12:30:20
0

从.NET Core 3.1到.NET 5,WWW-Authenticate头中的Realm已经被删除了,现在使用以下代码将认证方案名称添加到WWW-Authenticate头中:

  • 使用命名策略:
services.AddAuthorization(options =>
{
    options.DefaultPolicy = new AuthorizationPolicyBuilder()
        .AddAuthenticationSchemes("Bearer") // 认证方案名称
        .RequireAuthenticatedUser()
        .Build();
});

services.AddAuthentication("Bearer")
    .AddJwtBearer(options =>
    {
        options.Authority = "https://localhost:5001"; // 认证地址
        options.Audience = "api1"; // 目标资源
    });
  • 使用实例策略:
services.AddAuthentication(options =>
{
    options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
    options.Authority = "https://localhost:5001"; // 认证地址
    options.Audience = "api1"; // 目标资源
});

services.AddAuthorization(options =>
{
    options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme)
        .RequireAuthenticatedUser()
        .Build();
});

相关内容

热门资讯

透视黑科技(wepoke)外挂... 1、透视黑科技(wepoke)外挂透明挂辅助app(wepower辅助器)最初有挂(详细透视专业教程...
透视有挂(wepoke辅助挂)... 透视有挂(wepoke辅助挂)微扑克软件发牌原理(详细辅助科技教程)先前是有挂,您好,wepoke辅...
透视透视(wePOke)透明挂... 透视透视(wePOke)透明挂辅助工具(wepoke有没有挂)一贯是真的有挂(详细透视解密教程)是一...
透视黑科技(德州ai辅助有用)... 透视黑科技(德州ai辅助有用)cloudpoker辅助器(详细辅助普及教程)固有真的有挂;人气非常高...
透视规律(wePokE)透视辅... 透视规律(wePokE)透视辅助工具(WePoKe透视挂)果然真的是有挂(详细透视技巧教程);实战中...
透视透视(智星德州菠萝)wep... 透视透视(智星德州菠萝)wepower系统规律(详细辅助必胜教程)起初真的有挂1、许多玩家不知道智星...
透视存在(WepokE)外挂透... 透视存在(WepokE)外挂透明挂辅助软件(wepoke一定有挂)从前存在有挂(详细透视爆料教程);...
透视代打(微扑克ai机器人)w... 透视代打(微扑克ai机器人)wepokewopoker透明挂(详细辅助攻略教程)一向有挂1、微扑克a...
透视线上(wepOKE)透视辅... 此外,数据分析德州(wepokeai辅助)辅助神器app还具备辅助透视行为开挂功能,通过对客户wep...
透视工具(wepoke有挂)a... 透视工具(wepoke有挂)aa poker智能ai辅助介绍(详细辅助切实教程)一向是真的有挂,您好...