IdentityServer Topics(6)- Windows身份驗證


在Windows平台上,你可以讓IdentityServer使用 Windows身份驗證 對用戶進行身份驗證。 當你使用以下類型托管運行 IdentityServer 時, Windows身份驗證功能可用:

  • 使用Kestrel服務器但需要使用IIS integration或者IIS
  • 使用HTTP.sys服務器

在這兩種情況下,Windows身份認證將會觸發 HttpContext 的 ChallengeAsync 方法,使用 Scheme "Windows"。快速入門:quickstart UI 的 AccountController 實現了該邏輯,

使用Kestrel

當使用Kestrel,在代碼中使用IIS integration,且必須通過IIS來運行:

var host = new WebHostBuilder()
    .UseKestrel()
    .UseUrls("http://localhost:5000")
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration()
    .UseStartup<Startup>()
    .Build();

在使用WebHost.CreateDefaultBuilder方法設置WebHostBuilder時,Kestrel會自動配置。

此外,IIS(或IIS Express)中的虛擬目錄必須啟用Windows和匿名身份驗證。

IIS integration 層將配置一個Windows身份驗證處理程序到DI,可以通過身份驗證服務調用。 通常在IdentityServer中,建議禁用此自動行為。 可以在 ConfigureServices 中完成:

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM