Skip to content

CodeKong/OWIN-MixedAuth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OWIN Mixed Authentication

OWIN middleware implementation mixing Windows and Forms Authentication.

mixed-auth

Install with NuGet

PM> Install-Package OWIN-MixedAuth

Running the samples

Before running the samples, make sure to unlock windowsAuthentication section:

IIS

  1. Open IIS Manager, select the server node, then Feature Delegation.
  2. Set Authentication - Windows to Read/Write

unlock-section

IIS Express

  1. Open applicationhost.config located at $:\Users{username}\Documents\IISExpress\config
  2. Search for windowsAuthentication section and update overrideModeDefault value to Allow.
 <section name="windowsAuthentication" overrideModeDefault="Allow" />

Usage

  1. Add reference to MohammadYounes.Owin.Security.MixedAuth.dll

  2. Register MixedAuth in Global.asax

//add using statement
using MohammadYounes.Owin.Security.MixedAuth;

public class MyWebApplication : HttpApplication
{
   //ctor
   public MyWebApplication()
   {
     //register MixedAuth
     this.RegisterMixedAuth();
   }
   .
   .
   .
}
  1. Use MixedAuth in Startup.Auth.cs
//Enable Mixed Authentication
//As we are using LogonUserIdentity, its required to run in PipelineStage.PostAuthenticate
//Register this after any middleware that uses stage marker PipelineStage.Authenticate

app.UseMixedAuth(cookieOptions);

Important! MixedAuth is required to run in PipelineStage.PostAuthenticate, make sure the use statement is after any other middleware that uses PipelineStage.Authenticate. See OWIN Middleware in the IIS integrated pipeline.

  1. Enable Windows authentication in Web.config
<!-- Enable Mixed Auth -->
<location path="MixedAuth">
  <system.webServer>
    <security>
      <authentication>
        <windowsAuthentication enabled="true" />
      </authentication>
    </security>
  </system.webServer>
</location>

Important! Enabling windows authentication for a sub path requires windowsAuthentication section to be unlocked at a parent level.


Please share any issues you may have.

About

Mixed (Windows + Forms) Authentication for OWIN

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 49.2%
  • JavaScript 43.7%
  • Classic ASP 4.6%
  • HTML 1.9%
  • CSS 0.6%