身份服务器 4 Windows 身份验证

Dat*_*erd 5 iis windows-authentication asp.net-identity identityserver4 asp.net-core-2.0

我结合了这三个资源来开始使用 Identity Server 4。

  1. IdentityServer4.Quickstart.UI
  2. 4_ImplicitFlowAuthenticationWithExternal
  3. Combined_AspNetIdentity_and_EntityFrameworkStorage

这三者的组合用于将用户存储在数据库中,甚至来自外部供应商。还存储 Identity Server 4 配置,例如声明、角色、客户端和资源。我现在的主要问题是在 IIS Express 中运行时 Windows 身份验证按预期工作。一旦我在本地机器上发布到完整的 IIS 服务器,当我点击 Windows 外部登录页面时,我会得到一个重复的登录弹出窗口。在 IIS Express 中运行 Identity Server 4 时,我没有看到该弹出窗口。在 IIS Express 中,我可以单击 Windows 外部身份验证按钮。它通过应用程序正确路由并成功完成登录。

任何和所有的帮助都受到高度赞赏。我试图包含尽可能多的复制步骤,所以如果有任何不清楚的地方,请告诉我。

重复登录弹出窗口:

在此处输入图片说明

IIS 设置为启用了 Windows 身份验证和匿名身份验证。

在此处输入图片说明

Setup.CS(ConfigureServices 方法)

public void ConfigureServices(IServiceCollection services) {
        // Windows authentication is supported only by hosting Kestrel (Asp.net Core Web Server inside iis as a reverse proxy)
        // It is different than other Authentication methods because you don't Add the Authentication middleware like above.
        services.Configure<IISOptions>(options => {
            options.AuthenticationDisplayName = "Windows";
            options.AutomaticAuthentication = true;
        });

        services.AddMvc();
Run Code Online (Sandbox Code Playgroud)

程序.cs

public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();
Run Code Online (Sandbox Code Playgroud)

Dat*_*erd 2

幸运的是我自己回答了这个问题。这实际上不是软件开发人员的问题,而是环境配置的问题。由于应用程序是在本地部署的,因此本地环回检查导致了该问题。 https://support.microsoft.com/en-us/help/896861/you-receive-error-401-1-when-you-browse-a-web-site-that-uses-integrate