![](/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.