nullptr
nullptr

Reputation: 157

.Net Core and Azure AD B2C Setup

Is there a tutorial or setup guide for setting up Azure AD B2C in .Net Core? The sample code provided by the official documentation is very outdated and doesn't have much explanation.

Upvotes: 3

Views: 1109

Answers (2)

Martin Brandl
Martin Brandl

Reputation: 59011

There is not mutch you have to configure on your ASP.NET core application. The main part (beside configure your AAD B2C) is to add / set the authentication middleware to use jwt bearer and pass your tenant / policy to it.

Tutorial link.

Example configuration (taken from the tutorial):

services.AddAuthentication(options =>
  { 
    options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; 
  })
  .AddJwtBearer(jwtOptions =>
  {
    jwtOptions.Authority = $"https://login.microsoftonline.com/tfp/{Configuration["AzureAdB2C:Tenant"]}/{Configuration["AzureAdB2C:Policy"]}/v2.0/";
    jwtOptions.Audience = Configuration["AzureAdB2C:ClientId"];
    jwtOptions.Events = new JwtBearerEvents
    {
      OnAuthenticationFailed = AuthenticationFailed
    };
  });

Upvotes: 2

Related Questions