Implement NegotiateAuthentication API (#70720)
authorFilip Navara <navara@emclient.com>
Tue, 21 Jun 2022 11:38:18 +0000 (13:38 +0200)
committerGitHub <noreply@github.com>
Tue, 21 Jun 2022 11:38:18 +0000 (13:38 +0200)
commit79f6709eded51a0cfd8bcfcdf501dd42e4358113
treecb30afc87d6a83bb29b0ff9dff3535928440ba24
parent3b8a6f49bb965df0d64e819c213f3f0d796492ad
Implement NegotiateAuthentication API (#70720)

* WIP: Add implementation of NegotiateAuthentication

Switch System.Net.Http to use NegotiateAuthentication
Fix IsCompleted in managed NTLM implementation

* WIP: Update error code mapping

* Spanify input of GetOutgoingBlob

* Update comments

* Move NegotiateStreamPal.Encrypt/Decrypt to shared sources. Unix implementation already had them and they get trimmed anyway.

* Revert accidental change

* Build fixes.

* Fix error handling condition

* Update error mapping based on HttpListener usage.

* WIP: HttpListener test

* Move workaround from HttpListener to low-level SSPI code

* Fix build

* Clean up

* Revert "WIP: HttpListener test"

This reverts commit 18d7d93f04c93e048efcaca0f3c55c3f1f73516a.

* Convert System.Net.Http.FunctionalTests to use NegotiateAuthentication instead of NTAuthentication

* Dispose the identity along NegotiateAuthentication

* Modify unit tests to use the new API

* Add exceptions for invalid inputs/states

* Remove tvOS unsupported marker, managed NTLM is used on tvOS

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix typo

* Remove reference equality checks from IsNTLM/IsKerberos

* Remove NTAuthentication.AssociatedName to make it more obvious which exceptions are thrown

* Add comment

* Add more tests, handle unsupported protocols

* Handle NotSupportedException from NTAuthentication constructor

* Add workaround for linker issue

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
31 files changed:
src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs
src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.PlatformNotSupported.cs [deleted file]
src/libraries/Common/src/System/Net/ContextFlagsAdapterPal.PlatformNotSupported.cs [deleted file]
src/libraries/Common/src/System/Net/NTAuthentication.Common.cs
src/libraries/Common/src/System/Net/NTAuthentication.Managed.cs
src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.PlatformNotSupported.cs [deleted file]
src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Unix.cs
src/libraries/Common/src/System/Net/Security/NegotiateStreamPal.Windows.cs
src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnValueReader.cs
src/libraries/System.Net.Http/src/Resources/Strings.resx
src/libraries/System.Net.Http/src/System.Net.Http.csproj
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.tvOS.cs [deleted file]
src/libraries/System.Net.Http/tests/FunctionalTests/NtAuthTests.Windows.cs
src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
src/libraries/System.Net.HttpListener/src/Resources/Strings.resx
src/libraries/System.Net.Mail/src/Resources/Strings.resx
src/libraries/System.Net.Security/ref/System.Net.Security.cs
src/libraries/System.Net.Security/src/Resources/Strings.resx
src/libraries/System.Net.Security/src/System.Net.Security.csproj
src/libraries/System.Net.Security/src/System/Net/NTAuthentication.cs
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthentication.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthenticationClientOptions.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthenticationServerOptions.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthenticationStatusCode.cs [new file with mode: 0644]
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStreamPal.PlatformNotSupported.cs
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStreamPal.Unix.cs
src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStreamPal.Windows.cs
src/libraries/System.Net.Security/tests/UnitTests/NTAuthenticationTests.cs
src/libraries/System.Net.Security/tests/UnitTests/NegotiateAuthenticationTests.cs [new file with mode: 0644]
src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj