Cannot login with local account after adding Auth0

Hi,

I´m using a classic ASP.NET MVC application with ASP.NET Identity und local accounts (stored in SQL DB). After adding Auth0 as described in the tutorial

builder.Services.AddAuth0WebAppAuthentication(options =>
{
    options.Domain = "...";
    options.ClientId = "...";
});

I´m no longer able to login with my existing local accounts. After I login with the usual call

_signInManager.PasswordSignInAsync(...)

the ClaimsIndentity set in the User context is empty. It has no claims and all properties are null. Do I have to add Auth0 in a different way in order to use local accounts and Auto0 with external accounts parallel?

Thx in advance

Hey there!

Can you share with us here the link to the tutorial you are using? Thank you!

yes of course, I used this tutorial:

After some investigation do I need to follow the OWIN-tutorial?

I figured out that ASP.NET Identity is based on OWIN and so I hope that this is the correct approach. My requirement is to add Auth0 as authentication provider additionally to the existing ASP.NET Identity cookie based authentication (username/password stored in local database). Is that in general possible?

There is no need to go through Owin, especially if you are doing ASP .Net core. In Auth0 instruction, they assume you don’t identify providers, so they say:

builder.Services.AddAuth0WebAppAuthentication(
    options =>
    {
        options.Domain = ...'
        options.ClientId = ...;
    });

Here is what my code looks like, and I can use asp.net core Identity and Auth0.

services.AddDbContext<ApplicationDbContext>(options =>
    options.UseSqlServer(connectionString));
services.AddDatabaseDeveloperPageExceptionFilter();
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<ApplicationDbContext>();
services.Configure<CookiePolicyOptions>(options =>
{
    options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAuthentication()
    .AddAuth0WebAppAuthentication(auth0Options =>
    {
        auth0Options.Domain = ...;
        auth0Options.ClientId = ...;
    });
services.AddControllersWithViews();
var app = builder.Build();