Restructure NegotiateAuthentication implementation (#87930)
authorFilip Navara <navara@emclient.com>
Tue, 18 Jul 2023 14:02:49 +0000 (16:02 +0200)
committerGitHub <noreply@github.com>
Tue, 18 Jul 2023 14:02:49 +0000 (08:02 -0600)
commitf7ad7265b222bede49ff93b341d81b61bd898122
tree51057c296f99d1d958e81809f1cf7e322bcc63ed
parentf1d60990067fe45bad99ceb1cc4fd79e3f03b3b0
Restructure NegotiateAuthentication implementation (#87930)

* Change NegotiateAuthentication implementation to use indirection through NegotiateAuthenticationPal to the actual implementation.

The PAL implementation are merged from different sources to follow the same structure:
- NTAuthentication.Managed.cs -> NegotiateAuthenticationPal.Managed.cs
- NTAuthentication.Common.cs + NegotiateStreamPal.Windows.cs -> NegotiateAuthenticationPal.Windows.cs
- NTAuthentication.Common.cs + NegotiateStreamPal.Unix.cs -> NegotiateAuthenticationPal.Unix.cs

This split allows to delete ContextFlagsPal, SafeDeleteNegoContext, and SafeFreeNegoCredentials abstractions that were used in NegotiateStreamPal.

* Unify impersonation level validation between Windows and Unix pllatforms

* Split managed NTLM and managed SPNEGO implementations; add UseManagedNtlm switch on Unix platforms

* Remove debug cruft

* Fix couple of errors in managed SPNEGO

* Remove debug print

* Fix message sequence in managed NTLM; remove unused method

* Fix fallbacks on macOS GSSAPI

* Cleanup and fallbacks for missing NTLM, GSSAPI

* Adjust tests to assume that NTLM is always available on Unix

* Don't claim NTLM support on Browser

* Revert "Don't claim NTLM support on Browser"

This reverts commit 87d0c56f67a5269d9b334ab17887338ac4cfe49b.

* Attempt to fix the browser tests

* Revert "Attempt to fix the browser tests"

This reverts commit 91d7ce289a7274b682803b1d5dfdf418a5c2120c.

* Browser test suppression

* Respect UseManagedNtlm=false on platforms without NTLM GSSAPI provider

* Update src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs

* Revert all the fallback code paths, System.Net.Security.UseManagedNtlm has to be enabled explicitly; NativeAOT on Linux Bionic does that by default because it doesn't have GSSAPI and native shim
25 files changed:
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
src/libraries/Common/src/System/Net/Security/Unix/SafeDeleteNegoContext.cs [deleted file]
src/libraries/Common/src/System/Net/Security/Unix/SafeFreeNegoCredentials.cs [deleted file]
src/libraries/System.Net.Http/tests/FunctionalTests/NtAuthTests.FakeServer.cs
src/libraries/System.Net.Security/src/ILLink/ILLink.Substitutions.xml [new file with mode: 0644]
src/libraries/System.Net.Security/src/System.Net.Security.csproj
src/libraries/System.Net.Security/src/System/Net/ContextFlagsAdapterPal.Unix.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/ContextFlagsAdapterPal.Windows.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/ContextFlagsPal.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/NTAuthentication.Common.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/NTAuthentication.Managed.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/NTAuthentication.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Managed.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedSpnego.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unsupported.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Windows.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthentication.cs
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthenticationStatusCode.cs
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStream.cs
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStreamPal.Managed.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStreamPal.Unix.cs [deleted file]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStreamPal.Windows.cs [deleted file]