要使用Windows身份验证进行授权,需要在ASP.NET Core应用程序的Startup类中进行以下配置:
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.AddAuthorization(options => { options.AddPolicy("WindowsUser", policy => { policy.AuthenticationSchemes.Add(IISDefaults.AuthenticationScheme); policy.RequireAuthenticatedUser(); }); });
[Authorize(Policy = "WindowsUser")] public IActionResult WindowsAuthenticatedAction() { // Perform action here return View(); }
这样就可以使用Windows身份验证进行ASP.NET Core 3.1应用程序的授权操作了。