身份服务器4 Windows身份验证

5
我已经参考了这三个资源来开始使用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外部身份验证按钮,它会正确地进行路由,并成功完成登录。
非常感谢任何形式的帮助。我尝试包含尽可能多的复制步骤,如果有任何不清楚的地方,请告诉我。
重复登录弹出窗口:

enter image description here

IIS已设置为启用Windows认证和匿名认证。

enter image description here

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();

Program.cs

public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();
2个回答

2

链接已经失效了,但是可以在互联网档案馆上找到:[https://web.archive.org/web/*/https://support.microsoft.com/en-us/help/896861/you-receive-error-401-1-when-you-browse-a-web-site-that-uses-integrate] - rob3c
这是一个最新的链接,具有相同的分辨率步骤:https://support.microsoft.com/en-us/help/926642/error-message-when-you-try-to-access-a-server-locally-by-using-its-fqd - Jorge Cabot

0

如果你的代码在 Express 中可以工作但在 Full 中不行,那么很可能是 IIS 在验证你输入的 Windows 凭据时出现了权限问题。请确保你的应用程序池账户有权限验证你域中的凭据。


我目前正在使用我的应用程序池凭据。我认为这是一个环境设置问题,但确实很令人沮丧,因为不知道需要更改的是环境还是环境代码。 - DataNerd
需要哪种类型的帐户来验证域中的凭据?我已经使用AppPoolIdentity有一段时间了。我也需要在某个时候设置IDSVR4与Windows Auth。 - IbrarMumtaz
@IbrarMumtaz 在你的域上有读取权限的东西。AppPoolIdentity是一个仅限本地的帐户,没有网络请求。我会使用域帐户。也可以使用Network Service。 - Dan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接