Code Monkey home page Code Monkey logo

mvc5-mixedauth's Introduction

Important Announcement

This project is more of a proof of concept that makes mixed authentication appear as if its an external provider. I recommend using OWIN-MixedAuth, because its modular and works seamlessly with other authentication providers.

ASP.NET MVC 5 Mixed Authentication

Mixing Windows and Forms Authentication (Windows + Forms) Login

===========

Visual Studio Update 3

A new updated branch is available here. Also view this comparison for the list of changes required to add Mixed Authentication support.

How its done ?

The basic idea is to have a managed handler to perform windows authentication, then hand control over to the cookies authentication middleware.

It will appear as if its an external provider. Sample Screens

Running the solution locally

No special requirements! Visual Studio Express 2013 is all you need.

  • Clone the repository: git clone [email protected]:MohammadYounes/MVC5-MixedAuth.git

  • Open the solution using Visual Studio, build and run.

Enabling Windows Authentication on IIS Express.

  • From Solution Explorer, select MixedAuth project then press F4 to view Project Properties and Make sure "Windows Authentication" is enabled.

    IIS Express

Importing AD Groups as Role Claims:

All AD groups asscociated with the user windows account are available when you hit the WindowsLogin Action, you can fetch all of them by iterating over Request.LogonUserIdentity.Groups:

private void MapGroupsToRoleClaims(ApplicationUser user)
{
  foreach (var group in Request.LogonUserIdentity.Groups)  
    user.Claims.Add(new IdentityUserClaim()
    {
      ClaimType = ClaimTypes.Role,
      ClaimValue = new SecurityIdentifier(group.Value)
                         .Translate(typeof(NTAccount)).Value
    });
}
Flowchart of the Windows Login / Link code flow (Contributed by @ComboFusion)

mixedauth-windowsloginhandler


Please share any issues you may have.

mvc5-mixedauth's People

Contributors

mohammadyounes avatar macropus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.