[英]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.cs
的ConfigureServices
方法中的这些行一样简单:
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.