C# 标识的方案名称是什么?
假设我使用以下方法:C# 标识的方案名称是什么?,c#,asp.net-core,asp.net-identity,asp.net-core-identity,.net-core-authorization,C#,Asp.net Core,Asp.net Identity,Asp.net Core Identity,.net Core Authorization,假设我使用以下方法: services.AddIdentity<User, UserRole>() .AddEntityFrameworkStores<AppDbContext>(); services.AddIdentity() .AddEntityFrameworkStores(); 正在设置的身份验证方案名称是什么?我在任何文档中都没有找到这个。我试图寻找一个名为IdentityAuthenticationDefaults和IdentityDef
services.AddIdentity<User, UserRole>()
.AddEntityFrameworkStores<AppDbContext>();
services.AddIdentity()
.AddEntityFrameworkStores();
正在设置的身份验证方案名称是什么?我在任何文档中都没有找到这个。我试图寻找一个名为IdentityAuthenticationDefaults
和IdentityDefaults
的类,但什么也找不到。我尝试过“饼干”,但它没有设置为这个。应用程序运行良好,因此肯定有一些方案名称集 是您在这里寻找的课程。以下是您具体问题的相关部分(已删除xmldocs):
IdentityConstants.ApplicationScheme
用作DefaultAuthenticateScheme
-值本身最终为Identity.Application
这些计划已设立:
以下是API参考文档的链接:
public class SharedConstants
{
public const string IdentityApplicationScheme = "Identity.Application";
}
然后你可以像这样使用它
[Authorize(AuthenticationSchemes = SharedConstants.IdentityApplicationScheme)]
谢谢,它解决了这个问题。然而,由于这不是一个常数,有没有关于如何在没有硬编码身份的情况下使用它的想法?我想创建一个自定义身份验证方案需要很长的路要走。一个自定义策略应该适合这一点-请参阅以了解其工作原理。
public class SharedConstants
{
public const string IdentityApplicationScheme = "Identity.Application";
}
[Authorize(AuthenticationSchemes = SharedConstants.IdentityApplicationScheme)]