.net - HttpContext.User.Identity.AuthenticationType 的可能值

标签 .net asp.net-core asp.net-core-identity

在 ASP.NET Core 中,通过 Identity,我总是得到这个:

HttpContext.User.Identity.AuthenticationType == "Identity.Application"

这有什么意义呢?还有其他值吗?

最佳答案

当我设置所有内容以使用 Windows 身份验证时,我得到 HttpContext.User.Identity.AuthenticationType = Kerberos,这就是一个示例。

此外,当我自己登录时:

        ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(
            new List<Claim>{
                new Claim(ClaimTypes.Name, username),
                new Claim(PartnersUserDataClaim, userData),
                new Claim(ModuleNameClaim, moduleName)
            },
            "SSO/Windows"));

        await HttpContext.Authentication.SignInAsync(APIAuthSchemeName, principal);

“SSO/Windows” 最终成为 HttpContext.User.Identity.AuthenticationType

的值

所以,我想说这个属性可以由任何能够创建主体的层来设置,无论是提供的中间件(例如用于 Kerberos 的 IIS 中间件)还是您自己的层。

关于.net - HttpContext.User.Identity.AuthenticationType 的可能值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42669391/

相关文章:

c# - 当我的应用程序使用不同的 appsettings 文件时,为什么 AspNetCore Identity 脚手架不会加载其关联的 CSS 和 JS 文件?

.net - 在哪里知道/检查: Int32 inherits from ValueType, ValueType继承自Object?

visual-studio - Visual Studio 无需重建代码即可查看 html 更改

c# - 如何检索 EF Core 中动态属性的值

c# - 从 ASP.NET CORE 2 获取当前用户

c# - InvalidOperationException : Scheme already exists: Identity. 应用程序

asp.net-core - ForbidAsync 与 ChallengeAsync 为什么以及何时使用它们

.net - 为 MySQL 数据库编写前端程序

c# - WPF ListBox 将 SelectedItem 值发送到 View 模型

.net - 如何设置组合框自动完成下拉菜单中使用的字体