Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identityserver 4 and Azure AD

I'm looking into using Identity Server 4 for authentication within a C# based MVC application. I'd like to use accounts stored in Azure AD as a source of valid users but the documentation only seems to refer to Google and OpenID & only mentions Azure in passing.

Does anybody know of any good documentation and/or tutorials on how to use Azure AD in the context of using it with Identity Server 4?

like image 287
Patrick Avatar asked Feb 01 '17 10:02

Patrick


People also ask

Is Azure AD an IDaaS?

Azure Active Directory (Azure AD) is a comprehensive identity as a service (IDaaS) solution used by millions of organizations that span all aspects of identity, access management, and security.

Does Azure support OIDC?

OpenID Connect is an authentication protocol built on top of OAuth 2.0 that can be used for secure user sign-in. Most identity providers that use this protocol are supported in Azure AD B2C.

What is synchronized identity in Azure AD?

Synchronized: these are identities that exist on-premises and in the cloud. Using Azure AD Connect, these users are either created or joined with existing Azure AD accounts. The user's password hash is synchronized from the on-premises environment to the cloud in what is called a password hash.

What is Azure AD identity management?

Azure AD is a multitenant, cloud-based directory and identity management service from Microsoft. It combines core directory services, application access management, and identity protection into a single solution.


1 Answers

You can use signin to Azure AD from IdentityServer just as you would use signin to IdentityServer from e.g. a Javascript or MVC app.

I have done this recently, and all you need to do is register OpenIdConnect options to Azure Ad like this:

public void ConfigureAuth(IAppBuilder app) {     app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);      app.UseCookieAuthentication(new CookieAuthenticationOptions());      app.UseOpenIdConnectAuthentication(         new OpenIdConnectAuthenticationOptions         {             ClientId = clientId,             Authority = authority,             PostLogoutRedirectUri = postLogoutRedirectUri,         }); } 

More info about this here: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-devquickstarts-webapp-dotnet

You should then in your Login action call the ChallengeAsync method:

var authenticationProperties = new AuthenticationProperties { RedirectUri = "your redirect uri" }; await HttpContext.Authentication.ChallengeAsync(your policy, authenticationProperties); 

Then provide a callback method as a GET method then follow the External Login samples provided in IdentityServer samples: https://github.com/IdentityServer/IdentityServer4.Samples/blob/dev/Quickstarts/4_ImplicitFlowAuthenticationWithExternal/src/QuickstartIdentityServer/Quickstart/Account/AccountController.cs

like image 194
Espen Medbø Avatar answered Sep 22 '22 20:09

Espen Medbø