c# - 身份的方案名称是什么?
问题描述
假设我使用以下内容:
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
.
计划在这里设置:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = IdentityConstants.ApplicationScheme;
options.DefaultChallengeScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
以下是 API 参考文档的链接:
推荐阅读
- python - 安装 `dulwich` 给出`error: command 'clang' failed with exit status 1`
- php - 始终显示 404 php 基本路由
- azure-devops - Azure DevOps:迁移到 .NET Core 3.0 后管道中断
- c++ - “gcc72-c++”中的“72”是什么意思
- linux - Ansible 在尝试运行任务以将模板复制到目标后暂停
- nativescript - Nativescript 6 升级 - Android 构建现在失败
- python-3.x - 为什么生成器对象不是返回生成器?
- java - 您如何使位图图像在其移动和转动的整个过程中都指向前方?
- excel - 在列中添加数字
- sql - 汇总列时的操作数错误消息