简体   繁体   English

如何使用多租户ASP.NET应用程序通过Azure Active Directory进行身份验证?

[英]How do I authenticate via Azure Active Directory with multi-tenant ASP.NET applications?

I have been doing some tests with Azure Active Directory trial license in my data center. 我一直在我的数据中心使用Azure Active Directory试用许可证进行一些测试。 Our company has our own hosting services and physical hardware, and for now we would like to keep it that way (though we may investigate moving it all to cloud services in future). 我们公司拥有自己的托管服务和物理硬件,现在我们希望保持这种方式(尽管我们可能会考虑将其全部转移到云服务中)。

For now, we are trying to provide a single sign-on option for our customers using Azure AD. 目前,我们正在尝试使用Azure AD为我们的客户提供单一登录选项。 We already support this with CAS, but some customers are already using Azure AD internally and want to use this as the integrated Windows Authentication method with IIS & ASP.NET. 我们已经使用CAS支持此功能,但有些客户已在内部使用Azure AD,并希望将其用作IIS和ASP.NET的集成Windows身份验证方法。

How do I go about setting this up in a way that supports multiple tenants? 如何以支持多个租户的方式进行设置? I am having trouble figuring out how to do this at the IIS level, and am finding the literature a bit lacking with respect to a clear answer. 我无法弄清楚如何在IIS级别执行此操作,并且我发现文献在明确的答案方面有点缺乏。

As best I can tell, I would have to create a VM (separate Windows Server instance) for each customer, that is configured to authenticate via Azure AD and passes the windows auth credentials to IIS. 据我所知,我必须为每个客户创建一个VM(单独的Windows Server实例),配置为通过Azure AD进行身份验证并将Windows身份验证凭据传递给IIS。 This is kind of annoying. 这有点烦人。

Is there a way that I can continue to run IIS and ASP.NET web apps on my own server, but use Azure AD for Windows Authentication with ASP.NET, where each IIS web app instance has its own separate Azure AD configuration? 有没有办法可以继续在我自己的服务器上运行IIS和ASP.NET Web应用程序,但是使用Azure AD进行Windows身份验证,其中每个IIS Web应用程序实例都有自己独立的Azure AD配置?

Can I do this at the web app root folder level? 我可以在Web应用程序根文件夹级别执行此操作吗? (Perhaps by setting the authorization for that folder to grant permissions to users in that customer's Azure AD?) (也许通过设置该文件夹的授权以向该客户的Azure AD中的用户授予权限?)

My goal, for example, given this Windows Server configuration: 我的目标,例如,给定此Windows Server配置:

  • Host (IIS 8) "webhost" 主机(IIS 8)“webhost”
    • Web app "A", c:\\apps\\a , authorized users include AAD "A" users Web应用程序“A”, c:\\apps\\a ,授权用户包括AAD“A”用户
    • Web app "B", c:\\apps\\b , authorized users include AAD "B" users Web应用程序“B”, c:\\apps\\b ,授权用户包括AAD“B”用户

Users from customer A use this url: http://webhost/a 来自客户A的用户使用此URL: http://webhost/a

Users from customer B use this url: http://webhost/b 来自客户B的用户使用此URL: http://webhost/b

When user A browses to web app A, the integrated windows authentication should either challenge user for Azure AD "A" windows username & password, or, if already authenticated, show the user content from web app A. 当用户A浏览到Web应用程序A时,集成的Windows身份验证应该向用户提出Azure AD“A”窗口用户名和密码,或者,如果已经过身份验证,则显示来自Web应用程序A的用户内容。

When user B browses to web app B, the integrated windows authentication should either challenge user for Azure AD "B" windows username & password, or, if already authenticated, show the user content from web app B. 当用户B浏览到Web应用B时,集成的Windows身份验证应该向用户提出Azure AD“B”窗口用户名和密码,或者,如果已经过身份验证,则显示来自Web应用B的用户内容。

Thanks! 谢谢!

You can most definitely leverage Azure AD on apps running on your own server. 您绝对可以在自己的服务器上运行的应用程序上利用Azure AD。 You should not need to apply settings at the IIS level. 您不需要在IIS级别应用设置。 When you use Azure AD the windows integrated auth would take place between the client and Azure AD endpoints - that results in a token that is sent to the app on a channel that does not require windows integrated authentication. 当您使用Azure AD时,Windows集成身份验证将在客户端和Azure AD端点之间进行 - 这将导致在不需要Windows集成身份验证的通道上发送到应用程序的令牌。 That's what allows your apps to be hosted anywhere, there is no infrastructural constraint on the app itself. 这就是允许您的应用程序在任何地方托管的原因,应用程序本身没有基础设施限制。 Take a look at this sample for instructions on how to set up one app to trust an Azure AD tenant. 请查看此示例,了解有关如何设置一个应用程序以信任Azure AD租户的说明。 You can apply the same process to all your apps, pointing them to different AAD tenants. 您可以对所有应用程序应用相同的过程,将它们指向不同的AAD租户。 Once you have done that: you can skip the interstitial auth page and get windows integrated auth by following the instructions here . 完成后:您可以跳过插页式auth页面并按照此处的说明获取Windows集成身份验证。 I recommend you first get the sample to work, and only then focus on this last part. 我建议你先让样本工作,然后再关注最后一部分。 Tackling both things at once could be hard. 一次解决这两件事可能很难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM