首页 > 解决方案 > 除非明确指定,否则为什么不使用默认身份验证模式?

问题描述

这就是我设置默认方案的方式:

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
    .AddIdentityServerAuthentication();

如果我在我的控制器上使用它,它可以工作:

[Authorize(AuthenticationSchemas = IdentityServerAuthenticationDefaults.AuthenticationScheme)]

但是,如果我将其替换为仅[Authorize]响应变为Unauthorized. 我希望[Authorize]工作相同,因为该方案已设置为默认值。

这可能是什么原因?

标签: c#asp.net-coreauthenticationidentityserver4

解决方案


推荐阅读