Gra*_*aum 5 c# iis windows-authentication .net-core asp.net-core
好的Stackoverflow,经过无济于事的研究之后,我终于来到了这里!
我试图通过Windows身份验证和SSL从IIS托管一个.NET Core 2.0站点,无论我如何尝试,都会继续出现不一致/间歇性的403访问被拒绝错误。
如果出现某些错误,我希望它永远不会起作用。但是,如果我重新启动网站和应用程序池,它可能会起作用〜3/10次。在事件查看器,应用程序日志或IIS跟踪日志中找不到任何有用的东西。
我做的事情没有特别的顺序:
更详细的一点是,我试图与来自建立单向信任关系的其他域中的用户进行身份验证。我将使用来自“其他”域的凭据迁移到主机,因此它具有可见性。
这是我的web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MCP.MVP.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true" startupTimeLimit="3600" requestTimeout="23:00:00" />
<defaultDocument>
<files>
<add value="/home/index" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
<!--ProjectGuid: [REDACTED] -->
Run Code Online (Sandbox Code Playgroud)
从Startup.cs:
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.Configure<IISOptions>(options =>
{
options.AutomaticAuthentication = true;
});
Run Code Online (Sandbox Code Playgroud)
从Program.cs
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
Run Code Online (Sandbox Code Playgroud)
随处使用Authorize属性:
[Authorize(Policy = "RequireViewerRole")]
Run Code Online (Sandbox Code Playgroud)
授权胶水,其中Configuration [“ RequireViewerRoles”]是用逗号分隔的域组列表:
services.AddAuthorization(options =>
{
options.AddPolicy("RequireViewerRole", policy => policy.RequireRole(Configuration["RequireViewerRoles"].Split(',')));
});
Run Code Online (Sandbox Code Playgroud)
我是否已经进入.NET Core 2.0 Bug领域,或者我缺少什么?
原来这是一条巨大的红鲱鱼!
这是 401.2“无效服务器配置”错误。我终于注意到一种模式,如果我打开文件夹安全权限对话框,应用程序将工作,这将强制访问域控制器并缓存来自用户域的组名称。该应用程序可以正常工作大约 5 分钟,然后拒绝再次进行身份验证且未进行任何其他更改。
通过在组上配置域名解决了该问题,回想起来这是显而易见的。(域名\\域用户)。事实上,它在没有域名的情况下也能工作,这导致了很多混乱。IIS 日志中没有任何内容表明此错误,最终通过反复试验解决了该问题。
| 归档时间: |
|
| 查看次数: |
1680 次 |
| 最近记录: |