Reputation: 499
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. How to achieve this without modifying the code extensively. Here is the code: (we use OAuth,Owin middleware to enable third party auth). Can it be easily extended for Azure AD authentication (Please note the application should support multi tenancy.)
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
Upvotes: 0
Views: 250
Reputation: 3461
Yes, you can add Azure AD authentication.
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
:
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.
Upvotes: 1