Reputation: 157
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
Reputation: 16031
Microsoft just released some new docs on ASP.NET Core:
Upvotes: 1
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.
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