IdentityServer4 & Windows 认证

IdentityServer4 & Windows Authentication

我一直在追寻这个问题一段时间,但我无法深入了解它。我已经阅读了此处的其他解决方案 (https://identityserver4.readthedocs.io and https://github.com/IdentityServer/IdentityServer4.Quickstart.UI),但它仍然无法正常工作,因此我试图将其简化为绝对基础。这不是我面临的实际问题,但会产生完全相同的结果。即我无法使 Windows 身份验证工作。

  1. 我克隆https://github.com/IdentityServer/IdentityServer4.Samples
  2. 我修改Quickstarts/7_JavaScriptClient/src/QuickstartIdentityServer/Quickstart/Account/AccountController.cs,使WindowsAuthenticationEnabledtrue
  3. 然后我转到 http://localhost:5000/account/login 并尝试使用 Windows 外部提供商,但我收到 401。

这里的这个简单示例与我在实际系统上看到的唯一区别是,我在真实站点上遇到凭据挑战。

调试我从未见过 if(HttpContext.User is WindowsPrincipal) 成功的代码,因为它总是 ClaimsPrincipal

有人可以向我解释我做错了什么吗?

您的 IIS 站点是否启用了 windows 身份验证?这需要启用才能分配您的 WindowsPrincipal。请注意,windows 身份验证仅在 运行 位于 IIS 或 IIS Express 之后才有效。