owin自我主机与Windows身份验证 - AllowAnonymous无法正常工作

时间:2017-08-03 13:21:05

标签: c# asp.net-web-api owin windows-authentication

我已启用Windows身份验证as described here

一切正常,只是一个小问题:这样做会使每个控制器方法都受到Windows身份验证的保护。没问题我想,只需在匿名访问可以使用的少数控制器方法上使用[AllowAnonymous]装饰器,但这不会起作用。

有没有办法让自主机没有授权每个控制器上的每个方法?

1 个答案:

答案 0 :(得分:2)

您必须启用Windows身份验证匿名身份验证。 documentation。你也告诉Owin需要Windows身份验证并禁止其他任何操作。

在你引用的代码中,你会改变这个:

listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication 
                               | AuthenticationSchemes.Anonymous;
相关问题