builder.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidIssuer = authOptions.Issuer,
ValidAudience = authOptions.Audience,
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(authOptions.Key)),
};
})
.AddScheme<AuthServerAuthenticationSchemeOptions, AuthServerAuthenticationHandler>("CustomAuth", options => { options.Authority = authOptions.Authority; });
}
根据上面的代码,添加了多个身份验证,我想要实现的是,如果AddJwtBearer成功,那么请求应该转发到
自定义Auth
。
根据上述代码
自定义Auth
不会被击中
HandleAuthenticationAsync
,只有JwtBearer正在验证请求。