aspnetcore2aadauth icon indicating copy to clipboard operation
aspnetcore2aadauth copied to clipboard

No authenticationScheme was specified

Open JulienAlbo opened this issue 5 years ago • 2 comments

I need to had following line or get a "No authenticationScheme was specified" error on sign in.

In Startup.cs, when calling services.AddAuthentication : auth.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;

PS: u deserve more gits for that code ;-)

JulienAlbo avatar Mar 14 '19 15:03 JulienAlbo

What I've used in my apps is:

auth.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
auth.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
auth.DefaultForbidScheme = CookieAuthenticationDefaults.AuthenticationScheme;

SignInScheme is the scheme used to persist the user, so in this case, you say that you will use a cookie to store the logged-in user's claims. Maybe you haven't setup the default Challenge scheme which is what is triggered when a login is required.

P.S. Thanks :)

juunas11 avatar Mar 14 '19 16:03 juunas11

Also I need to update this sample with that default forbid scheme because if it isn't set, the default challenge scheme is used as fallback. And we don't usually want that here. Instead I'd rather show an access denied page via a path set in cookie auth.

juunas11 avatar Mar 14 '19 16:03 juunas11