简体   繁体   English

MVC中的个人身份验证和Azure AD

[英]Individual Authentication and Azure AD in MVC

We have Created a MVC application with Individual Authentication Enabled and supported google, twitter etc. We would like to extend the support to Azure AD as well in the same Azure application. 我们已经创建了启用了“个人身份验证”并支持google,twitter等的MVC应用程序。我们希望在同一Azure应用程序中也将支持扩展到Azure AD。 How to achieve this without modifying the code extensively. 如何在不大量修改代码的情况下实现这一目标。 Here is the code: (we use OAuth,Owin middleware to enable third party auth). 以下是代码:(我们使用OAuth,Owin中间件来启用第三方身份验证)。 Can it be easily extended for Azure AD authentication (Please note the application should support multi tenancy.) 是否可以轻松扩展它以进行Azure AD身份验证(请注意,该应用程序应支持多租户。)

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
        {
            ClientId = "xxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
            ClientSecret = "xxxxxxxxxxxxx", 
            Provider = new GoogleOAuth2AuthenticationProvider()

        }); 
 var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
        {
            AppId = "xxxxxxxxx",
            AppSecret = "xxxxxxxxxxxxxxxxxxxxxx",

            AuthenticationType = "Facebook",
            SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,

            Provider = new FacebookAuthenticationProvider
            {....

.. ..

在此处输入图片说明

Your valuable comments are welcome 欢迎您提出宝贵意见

Yes, you can add Azure AD authentication. 是的,您可以添加Azure AD身份验证。

In ASP.NET Core identity, adding Open ID Connect to Azure AD is as simple as these lines in the ConfigureServices method in Startup.cs : 在ASP.NET Core身份中,添加Open ID Connect到Azure AD就像在Startup.csConfigureServices方法中的这些行一样简单:

services.AddAuthentication()
    .AddOpenIdConnect(
        o =>
        {
            o.ClientId = Configuration["AzureAd:ClientId"];
            o.Authority = String.Format(
                "https://login.microsoftonline.com/{0}", Configuration["AzureAd:Tenant"]);
            o.SignedOutRedirectUri = Configuration["AzureAd:PostLogoutRedirectUri"];
            o.Events = new OpenIdConnectEvents()
            {
                OnRemoteFailure = OnRemoteAuthenticationFailure,
            };
        });

For multitenant applications you need to have common instead of the {0} in the Authority , and there may be some extra configuration to signify which tenant the application is defined in. 对于多租户应用程序,您需要在Authority拥有common而不是{0} ,并且可能会有一些额外的配置来表示定义该应用程序的租户。

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

相关问题 一个ASP.NET MVC应用程序中是否可以同时具有Azure AD和个人帐户身份验证? - Is it possible to have both Azure AD and Individual Account authentication in one ASP.NET MVC application? ASP.NET MVC Connected服务要删除我的个人身份验证以添加Azure AD身份验证,没有办法解决吗? - ASP.NET MVC Connected services wants to remove my Individual Authentication to add Azure AD Authentication, no way around this? ASP.NET MVC 5 中的 Azure AD 身份验证 - Azure AD authentication in ASP.NET MVC 5 适用于Azure AD的MVC / SPA身份验证方案 - MVC/SPA Authentication Scenarios for Azure AD Azure AD 多租户身份验证 - ASP.NET MVC 5 - Azure AD Multi Tenant Authentication - ASP.NET MVC 5 在同一MVC应用程序中使用表单身份验证和Azure AD登录 - Using form authentication and Azure AD login in same mvc application 如何将 Azure AD 身份验证添加到现有的 .NET MVC Web 应用程序? - How to add Azure AD Authentication to existing .NET MVC Web Application? Forms 和 Azure AD 认证 - Forms and Azure AD Authentication 如何通过MVC Azure AD身份验证从AD获取角色? - How can I get roles from AD with MVC Azure AD Authentication? 在MVC5中使用Azure AD和个人帐户混合cookie外部登录 - Mixing cookie external login using Azure AD and individual account in MVC5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM