gpt4 book ai didi

c# - 带有 Windows/AD 身份验证的 IdentityServer4 不起作用?

转载 作者:太空宇宙 更新时间:2023-11-03 12:05:00 24 4
gpt4 key购买 nike

我为 IdentityServer4 创建了一个新项目并包含了 QuickUI。然后我点击链接 http://docs.identityserver.io/en/latest/topics/windows.html添加 Windows 身份验证。

startup.cs

public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddTestUsers(Config.GetUsers())
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryClients(Config.GetClients());

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

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); }

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

Program.cs

public class Program
{
public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run();

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>();
}

但是,页面中仍然没有显示外部登录按钮https://localhost:44378/Account/Login .我发现 DisplayNameawait _schemeProvider.GetAllSchemesAsync()为空且 schema.Nameidsrv.external而不是 Windows (AccountOptions.WindowsAuthenticationSchemeName)。

AccountController.cs

private async Task<LoginViewModel> BuildLoginViewModelAsync(string returnUrl)

var schemes = await _schemeProvider.GetAllSchemesAsync();

var providers = schemes
.Where(x => x.DisplayName != null || // schemes.DisplayName is null
(x.Name.Equals(AccountOptions.WindowsAuthenticationSchemeName, // "idsrv.external" != "Windows"
StringComparison.OrdinalIgnoreCase))
)
.Select(x => new ExternalProvider
{
DisplayName = x.DisplayName,
AuthenticationScheme = x.Name
}).ToList();

如何解决这个问题?

顺便说一句,我只需要针对 Windows/AD 进行身份验证,因此我不需要外部按钮。如何更改代码?

最佳答案

它需要禁用“匿名身份验证”并启用“Windows 身份验证”。

关于c# - 带有 Windows/AD 身份验证的 IdentityServer4 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55521359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com