本文介绍了OWIN 的混合身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个通过两种方式验证用户的用户:

  1. 如果他们是内部用户,我们将通过 Windows 的活动目录进行身份验证
  2. 如果他们在网站上注册,则他们通过表单身份验证进行身份验证

在 MVC 3/4 中,我能够通过实现自定义成员资格提供程序和自定义角色提供程序来实现这一点.

在使用 OWIN 和 Identity 的 MVC 5 中是否可以实现相同的功能?如何实现?

解决方案

本质上,混合模式是带有 Windows 身份验证入口点的表单身份验证,一旦用户通过它,就会发生正常的表单身份验证流程.

>

源代码:https://github.com/MohammadYounes/MVC5-MixedAuth>

I have two authenticate users in two ways:

  1. If they are an internal user we authenticate through Windows' active directory
  2. If they registered with the site they authenticate through Forms Authentication

In MVC 3/4 I was able to accomplish this by implementing a custom membership provider and custom role provider.

Is the same possible in MVC 5 using OWIN and Identity and how can it be done?

解决方案

In essence a mixed mode is a forms authentication with a windows authentication entry point, once the user gets passed it, the normal forms authentication flow takes place.

So for windows authentication to work, I have to rely on one of the provided hosts, either IIS or Self-host (System.Net.HttpListener).

I made a solution that makes it look like an external provider, mapping windows identities as external logins.

Source code : https://github.com/MohammadYounes/MVC5-MixedAuth

这篇关于OWIN 的混合身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 10:17