Fix NegotitateStream (server) on Linux for NTLM (dotnet/corefx#42522)
authorDavid Shulman <david.shulman@microsoft.com>
Mon, 11 Nov 2019 23:49:41 +0000 (15:49 -0800)
committerGitHub <noreply@github.com>
Mon, 11 Nov 2019 23:49:41 +0000 (15:49 -0800)
commit18d611f9d423028deb5be2e51b99b5cbaef08f19
tree947906d25bdcc90a70eb0052a6448725e3d79afd
parenteb0628b7b08dc35ed2b5736ba73208afbded98d0
Fix NegotitateStream (server) on Linux for NTLM (dotnet/corefx#42522)

This PR is a follow up to PR dotnet/corefx#36827 which added support for Linux server-side
GSS-API (AcceptSecContext). This enabled NegotitateStream AuthenticateAsServer*
support. It also provided support for ASP.NET Core to allow Kestrel server to have
Negotiate authentication on Linux.

This PR fixes some problems with Negotiate (SPNEGO) fallback from Kerberos to NTLM.
Notably it passes in a correct GSS Acceptor credential so that fallback will work
correctly. As part of fixing that, I noticed some other problems with returning the
user-identity when NTLM is used.

This was tested in a separate enterprise testing environment that I have created.
It builds on technologies that we have started using like docker containers and Azure
pipelines (e.g. HttpStress). The environment is currently here:
https://dev.azure.com/systemnetncl/Enterprise%20Testing. The extra Kerberos tests
and container support is here: https://github.com/davidsh/networkingtests

When the repo merge is completed, I will work with the infra team to see what things
can be merged back into the main repo/CI pipeline and migrate the test sources to an
appropriate place in the new repo.

Contributes to dotnet/corefx#10041
Contributes to dotnet/corefx#24707
Contributes to dotnet/corefx#30150

Commit migrated from https://github.com/dotnet/corefx/commit/1054f1fba1b7222c138dcd20d8da80cd893fdd01
src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.GssBuffer.cs
src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs
src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs
src/libraries/Common/src/System/Net/ContextFlagsAdapterPal.Unix.cs
src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Unix.cs
src/libraries/Common/src/System/Net/Security/Unix/SafeDeleteNegoContext.cs
src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.c
src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h