假设我使用以下内容:
services.AddIdentity<User, UserRole>()
.AddEntityFrameworkStores<AppDbContext>();
什么是设置的身份验证方案名称?我没有在任何文档中找到它。我试着寻找一个名为IdentityAuthenticationDefaults
和IdentityDefaults
的课程,但一无所获。我尝试过“Cookies”,但不是这样。该应用程序运行良好,所以肯定有一些方案名称设置。
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参考文档的链接: