Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup OWIN with Windows authentication and a custom role provider

In MVC4 I enabled <authentication mode="Windows"/> in the web.config and created a custom role provider which then would automatically wrap the WindowsIdentity with a RolePrincipal for you. Worked like a charm.

How would you do this in MVC5 using OWIN and/or Microsoft.ASPNET.Identity?

like image 226
batkuip Avatar asked Oct 19 '13 23:10

batkuip


1 Answers

Its the similar way to configure in web.config or configure at IIS Website.

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

Above is sufficient for intranet application. For additional scenarios like providing additional claims transformation as well as mixed authentication, for ASP.NET application, you can use custom OWIN middleware handler.

Have a look at example of such WindowsPrincipalHandler. You need to register it in startup.cs like app.Use(typeof(WindowsPrincipalHandler))

like image 78
jd4u Avatar answered Oct 22 '22 03:10

jd4u