Я создал новый проект для 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. я обнаружил, что DisplayName
из await _schemeProvider.GetAllSchemesAsync()
равно нулю и schema.Name
равно idsrv.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, поэтому мне не нужны внешние кнопки.Как изменить код?