如何使用Windows身份验证和自定义角色提供程序设置OWIN

时间:2013-10-19 23:26:06

标签: authentication roleprovider asp.net-mvc-5 windows-identity owin

在MVC4中,我在web.config中启用了<authentication mode="Windows"/>并创建了一个自定义角色提供程序,然后自动将WindowsIdentity包裹为RolePrincipal。工作就像一个魅力。

如何使用OWIN和/或Microsoft.ASPNET.Identity在MVC5中执行此操作?

1 个答案:

答案 0 :(得分:10)

在web.config中配置或在IIS网站上配置的方式类似。

<authentication mode="Windows" />
<authorization>
  <deny users="?" />
</authorization>

以上内容适用于Intranet。对于其他方案(如提供其他声明转换以及混合身份验证),对于ASP.NET应用程序,您可以使用自定义OWIN中间件处理程序。

查看此类WindowsPrincipalHandler的示例。您需要在startup.cs中注册它,如app.Use(typeof(WindowsPrincipalHandler))

相关问题