身份的方案名称是什么?

问题描述 投票:0回答:1

假设我使用以下内容:

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

什么是设置的身份验证方案名称?我没有在任何文档中找到它。我试着寻找一个名为IdentityAuthenticationDefaultsIdentityDefaults的课程,但一无所获。我尝试过“Cookies”,但不是这样。该应用程序运行良好,所以肯定有一些方案名称设置。

c# asp.net-core asp.net-identity asp.net-core-identity .net-core-authorization
1个回答
5
投票

IdentityConstants是你在这里寻找的课程。以下是您特定问题的相关部分(xmldocs已删除):

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

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

    ...
}

IdentityConstants.ApplicationScheme被用作DefaultAuthenticateScheme - 价值本身最终成为Identity.Application

计划设置here

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

以下是API参考文档的链接:

© www.soinside.com 2019 - 2024. All rights reserved.