![](/img/trans.png)
[英]Is it possible to have both Azure AD and Individual Account authentication in one ASP.NET MVC application?
[英]Individual Authentication and Azure AD in MVC
我们已经创建了启用了“个人身份验证”并支持google,twitter等的MVC应用程序。我们希望在同一Azure应用程序中也将支持扩展到Azure AD。 如何在不大量修改代码的情况下实现这一目标。 以下是代码:(我们使用OAuth,Owin中间件来启用第三方身份验证)。 是否可以轻松扩展它以进行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
{....
..
欢迎您提出宝贵意见
是的,您可以添加Azure AD身份验证。
在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,
};
});
对于多租户应用程序,您需要在Authority
拥有common
而不是{0}
,并且可能会有一些额外的配置来表示定义该应用程序的租户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.