Identity Server 4 Windows身份验证登录按钮未与本地IIS一起显示

时间:2018-09-12 14:51:39

标签: asp.net-core windows-authentication identityserver4

我正在尝试使用oidc和Windows身份验证来设置Identity Server项目。

Windows身份验证不起作用,我遵循了默认教程并使用默认模板开始,在本地IIS中,我没有将Windows作为身份验证方案接收,因此Windows登录按钮未显示。

我已经阅读了几种可能的解决方案,但是它们都没有起作用,也许我只是错过了一件简单的事情。

我还想在我的本地IIS中对其进行配置(如果我切换到IISExpress,我会看到登录按钮)。

我目前在启动时有以下内容:

 public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseKestrel()
            //.UseUrls("http://localhost:5000")
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

配置服务:

public void ConfigureServices(IServiceCollection services)
    {
        string connectionString = Configuration.GetConnectionString("PostgreSQLConnection");
        var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

        JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseNpgsql(connectionString));

        services.AddIdentity<ApplicationUser, IdentityRole>()                 
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();

        services.AddTransient<IEmailSender, EmailSender>();

        services.AddMvc();

        services
            .AddIdentityServer()
            .AddDeveloperSigningCredential()
            .AddInMemoryPersistedGrants()
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryClients(Config.GetClients())
            .AddAspNetIdentity<ApplicationUser>();

        services.Configure<IISOptions>(options => {
            options.AuthenticationDisplayName = "Windows";
            options.AutomaticAuthentication = true;
        });

        services.AddScoped<IUserClaimsPrincipalFactory<ApplicationUser>, GeoItClaimsPrincipal>(); 

    }

配置

 if (env.IsDevelopment())
        {
            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();
        app.UseAuthentication();
        app.UseIdentityServer();
        app.UseMvcWithDefaultRoute();

在我的launchSettings.json和IIS中,我都将WindowsAuthentication和匿名认证都设置为true。

如果您依赖自动发现外部提供程序,我也很难理解文档,他们说必须在其中设置显示名称。 并且默认情况下,显示名称为空,并且您必须在IIS后面运行并使用IIS集成。

一个简单的示例会有所帮助,我不知道我在做什么错。

谢谢。

0 个答案:

没有答案