Authentication using Microsoft Identity with ASP.NET Core web applications
To authenticate using Azure AD B2C, we’ll use the Microsoft Identity platform. In this section, we’ll focus on creating accounts with Azure AD B2C, logging in, and invoking secured REST APIs with ASP.NET Core web applications.
Like with the minimal API we created earlier, a .NET template can be used. Invoke this command to create a new project:
dotnet new webapp -au IndividualB2C -o WebAppAuth
In creating this project, several NuGet packages are added for identities and authentication. These were discussed when we secured the API. An additional package that hasn’t been used before is Microsoft.Identity.Web.UI
. This package integrates with Microsoft.Identity.Web
and offers pre-built UI elements for login, logout, and profile management.
With the DI container configuration, authentication is added. So, we need to customize it for calling APIs:
WebAppAuth/Program.cs
IConfigurationSection...