When using IIS clientCertificateMappingAuthentication IIS properly authorizes user in AD but Request.HttpContext.User does not reflect that
Describe the bug
When using IIS clientCertificateMappingAuthentication IIS properly authorizes user in AD but Request.HttpContext.User does not reflect that
To Reproduce
Using this version of ASP.NET Core '2.2'
Use IIS Hosting. Configure web site in the following manner:
<location path="SiteName">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="false" />
<anonymousAuthentication enabled="false" />
<basicAuthentication enabled="false" />
<clientCertificateMappingAuthentication enabled="true" />
</authentication>
<access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
</security>
</system.webServer>
</location>
Configure services in the following way services.AddAuthentication(IISDefaults.AuthenticationScheme); services.AddAuthorization();
For http pipeline: app.UseAuthentication();
Result: In controller method Request.HttpContext.User IS NOT populated with windows principal Request.HttpContext.Connection.ClientCertificate IS populated IIS log files correctly show domain user, ie first request gets response 403.7, then after supplying certificate from browser IIS logs show correct user in the cs-username column.
Expected behavior
In controller method Request.HttpContext.User IS populated with windows principal Request.HttpContext.Connection.ClientCertificate IS populated IIS log files correctly show domain user, ie first request gets response 403.7, then after supplying certificate from browser IIS logs show correct user in the cs-username column.
Additional context
.NET Core SDK (reflecting any global.json): Version: 2.2.104 Commit: 73f036d4ac
Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.104\
Host (useful for support): Version: 2.2.2 Commit: a4fd7b2c84
.NET Core SDKs installed: 2.1.504 [C:\Program Files\dotnet\sdk] 2.2.104 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Are you using IIS In-process or out-of-process? We'd need to verify the behavior of both.
I am using in process handler.
We don't support the clientCertificateMapping feature right now. We do have native client certificate auth coming in 3.0 (see our preview6 announcement)