Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the scheme name for identity?

Let's say I use the following:

services.AddIdentity<User, UserRole>()
        .AddEntityFrameworkStores<AppDbContext>();

What is the authentication scheme name being set? I didn't find this in any documentation. I tried looking for a class with the names IdentityAuthenticationDefaults and IdentityDefaults but found nothing. I have tried "Cookies" but it isn't set to this. The application works well, so there is surely some scheme name set.

like image 1000
Neville Nazerane Avatar asked Dec 04 '22 18:12

Neville Nazerane


1 Answers

IdentityConstants is the class you're looking for here. Here's the relevant part for your specific question (xmldocs removed):

public class IdentityConstants
{
    private static readonly string CookiePrefix = "Identity";

    public static readonly string ApplicationScheme = CookiePrefix + ".Application";

    ...
}

IdentityConstants.ApplicationScheme is used as the DefaultAuthenticateScheme - the value itself ends up being Identity.Application.

The schemes get set up here:

services.AddAuthentication(options =>
{
    options.DefaultAuthenticateScheme = IdentityConstants.ApplicationScheme;
    options.DefaultChallengeScheme = IdentityConstants.ApplicationScheme;
    options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})

Here are links to the API reference docs:

  • IdentityConstants
  • IdentityConstants.ApplicationScheme
like image 69
Kirk Larkin Avatar answered Dec 13 '22 03:12

Kirk Larkin