aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

When using IIS clientCertificateMappingAuthentication IIS properly authorizes user in AD but Request.HttpContext.User does not reflect that

Open xprzemekw opened this issue 7 years ago • 3 comments

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]

xprzemekw avatar Mar 07 '19 14:03 xprzemekw

Are you using IIS In-process or out-of-process? We'd need to verify the behavior of both.

Tratcher avatar Mar 07 '19 17:03 Tratcher

I am using in process handler.

xprzemekw avatar Mar 07 '19 19:03 xprzemekw

We don't support the clientCertificateMapping feature right now. We do have native client certificate auth coming in 3.0 (see our preview6 announcement)

analogrelay avatar Jun 18 '19 22:06 analogrelay