Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure NegotiateAuthentication implementation #87930

Merged
merged 21 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4d6eb5e
Change NegotiateAuthentication implementation to use indirection thro…
filipnavara Jun 22, 2023
229b1af
Unify impersonation level validation between Windows and Unix pllatforms
filipnavara Jun 22, 2023
73b143c
Split managed NTLM and managed SPNEGO implementations; add UseManaged…
filipnavara Jun 24, 2023
b5836a4
Remove debug cruft
filipnavara Jun 24, 2023
4142cfa
Fix couple of errors in managed SPNEGO
filipnavara Jun 24, 2023
b1a879a
Remove debug print
filipnavara Jun 24, 2023
f082fcd
Fix message sequence in managed NTLM; remove unused method
filipnavara Jun 24, 2023
665cb21
Fix fallbacks on macOS GSSAPI
filipnavara Jun 26, 2023
6c04170
Cleanup and fallbacks for missing NTLM, GSSAPI
filipnavara Jun 26, 2023
1324d77
Adjust tests to assume that NTLM is always available on Unix
filipnavara Jun 26, 2023
87d0c56
Don't claim NTLM support on Browser
filipnavara Jun 26, 2023
0c707c4
Revert "Don't claim NTLM support on Browser"
filipnavara Jun 27, 2023
91d7ce2
Attempt to fix the browser tests
filipnavara Jun 27, 2023
e7fc8b5
Revert "Attempt to fix the browser tests"
filipnavara Jun 27, 2023
86d72dc
Browser test suppression
filipnavara Jun 27, 2023
ee6b728
Respect UseManagedNtlm=false on platforms without NTLM GSSAPI provider
filipnavara Jun 27, 2023
29f19fd
Merge remote-tracking branch 'origin/main' into NegotiateAuthenticati…
filipnavara Jul 6, 2023
e5ebc07
Update src/libraries/System.Net.Security/src/System/Net/NegotiateAuth…
filipnavara Jul 13, 2023
c58d44e
Merge branch 'main' into NegotiateAuthenticationPal
filipnavara Jul 17, 2023
aa22b0a
Revert all the fallback code paths, System.Net.Security.UseManagedNtl…
filipnavara Jul 17, 2023
a69e95a
Merge remote-tracking branch 'origin/main' into NegotiateAuthenticati…
filipnavara Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ public static partial class Capability
{
public static bool IsNtlmInstalled()
{
// GSS on Linux does not work with OpenSSL 3.0. Fix was submitted to gss-ntlm but it will take a while to make to
// all supported distributions. The second part of the check should be removed when it does.
return Interop.NetSecurityNative.IsNtlmInstalled() && (!PlatformDetection.IsOpenSslSupported || PlatformDetection.OpenSslVersion.Major < 3);
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the property at all? Or keep it for future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that depends on the answer in #87930 (comment). In any case I would not remove it as part of this PR, it would be separate change. Mainly there's a concern about Windows with NTLM disabled, so there would still be use for it.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ internal static async Task HandleAuthenticationRequestWithFakeServer(LoopbackSer
[ConditionalTheory(nameof(IsNtlmAvailable))]
[InlineData(true)]
[InlineData(false)]
[SkipOnPlatform(TestPlatforms.Browser, "Credentials and HttpListener is not supported on Browser")]
public async Task DefaultHandler_FakeServer_Success(bool useNtlm)
{
await LoopbackServer.CreateClientAndServerAsync(
Expand Down
29 changes: 11 additions & 18 deletions src/libraries/System.Net.Security/src/System.Net.Security.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
<DefineConstants Condition="'$(UseAndroidCrypto)' == 'true' or '$(UseAppleCrypto)' == 'true'">$(DefineConstants);SYSNETSECURITY_NO_OPENSSL</DefineConstants>
<GenAPIExcludeApiList>ReferenceAssemblyExclusions.txt</GenAPIExcludeApiList>
</PropertyGroup>
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" Condition="'$(UseManagedNtlm)' == 'true'" />
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows'" />
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
<Compile Include="System\Net\CertificateValidationPal.cs" />
<Compile Include="System\Net\NegotiateAuthenticationPal.cs" />
<Compile Include="System\Net\NegotiateAuthenticationPal.Unsupported.cs" />
<Compile Include="System\Net\SslStreamContext.cs" />
<Compile Include="System\Net\Security\AuthenticatedStream.cs" />
<Compile Include="System\Security\Authentication\AuthenticationException.cs" />
Expand Down Expand Up @@ -48,9 +50,7 @@
<Compile Include="System\Net\Security\TlsAlertType.cs" />
<Compile Include="System\Net\Security\TlsFrameHelper.cs" />
<!-- NegotiateStream -->
<Compile Include="System\Net\ContextFlagsPal.cs" />
<Compile Include="System\Net\SecurityStatusPal.cs" />
<Compile Include="System\Net\NTAuthentication.cs" />
<Compile Include="System\Net\StreamFramer.cs" />
<Compile Include="System\Net\Security\NegotiateStream.cs" />
<Compile Include="System\Security\Authentication\ExtendedProtection\ExtendedProtectionPolicy.cs" />
Expand Down Expand Up @@ -102,8 +102,6 @@
Link="Common\System\Net\Security\SSPIHandleCache.cs" />
<Compile Include="$(CommonPath)System\Net\NegotiationInfoClass.cs"
Link="Common\System\Net\NegotiationInfoClass.cs" />
<Compile Include="System\Net\NTAuthentication.Common.cs"
Condition="'$(UseManagedNtlm)' != 'true'" />
<Compile Include="$(CommonPath)System\HexConverter.cs"
Link="Common\System\HexConverter.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Expand Down Expand Up @@ -152,8 +150,8 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
<Compile Include="System\Net\CertificateValidationPal.Windows.cs" />
<Compile Include="System\Net\NegotiateAuthenticationPal.Windows.cs" />
<Compile Include="System\Net\Security\CipherSuitesPolicyPal.Windows.cs" />
<Compile Include="System\Net\Security\NegotiateStreamPal.Windows.cs" />
<Compile Include="System\Net\Security\SslStreamCertificateContext.Windows.cs" />
<Compile Include="System\Net\Security\SslStreamPal.Windows.cs" />
<Compile Include="System\Net\Security\SslConnectionInfo.Windows.cs" />
Expand All @@ -168,7 +166,6 @@
Link="Common\System\Net\Security\SecurityBufferType.Windows.cs" />
<!-- NegotiateStream -->
<Compile Include="System\Net\SecurityStatusAdapterPal.Windows.cs" />
<Compile Include="System\Net\ContextFlagsAdapterPal.Windows.cs" />
<Compile Include="$(CommonPath)System\Net\Security\SecurityContextTokenHandle.cs"
Link="Common\System\Net\Security\SecurityContextTokenHandle.cs" />
<!-- Interop -->
Expand Down Expand Up @@ -284,13 +281,9 @@
<Compile Include="System\Net\Security\Pal.Managed\SafeChannelBindingHandle.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows' and '$(UseManagedNtlm)' != 'true'">
<Compile Include="System\Net\NegotiateAuthenticationPal.Unix.cs" />
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\GssSafeHandles.cs"
Link="Common\Microsoft\Win32\SafeHandles\GssSafeHandles.cs" />
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteNegoContext.cs"
Link="Common\System\Net\Security\Unix\SafeDeleteNegoContext.cs" />
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeFreeNegoCredentials.cs"
Link="Common\System\Net\Security\Unix\SafeFreeNegoCredentials.cs" />
<Compile Include="System\Net\ContextFlagsAdapterPal.Unix.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.Initialization.cs"
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.Initialization.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.GssApiException.cs"
Expand All @@ -301,11 +294,13 @@
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.IsNtlmInstalled.cs"
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.IsNtlmInstalled.cs" />
<Compile Include="System\Net\Security\NegotiateStreamPal.Unix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(UseManagedNtlm)' == 'true'">
<Compile Include="System\Net\Security\NegotiateStreamPal.Managed.cs" />
<Compile Include="System\Net\NTAuthentication.Managed.cs" />
<Compile Include="System\Net\NegotiateAuthenticationPal.Managed.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows'">
<Compile Include="System\Net\NegotiateAuthenticationPal.ManagedNtlm.cs" />
<Compile Include="System\Net\NegotiateAuthenticationPal.ManagedSpnego.cs" />
<Compile Include="$(CommonPath)System\Net\Security\MD4.cs"
Link="Common\System\Net\Security\MD4.cs" />
<Compile Include="$(CommonPath)System\Net\Security\RC4.cs"
Expand Down Expand Up @@ -452,9 +447,7 @@
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows'">
<Reference Include="System.Diagnostics.StackTrace" />
<Reference Include="System.Security.Cryptography" />
</ItemGroup>
<ItemGroup Condition="'$(UseManagedNtlm)' == 'true'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Formats.Asn1\src\System.Formats.Asn1.csproj" />
<Reference Include="System.Runtime.Numerics" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Formats.Asn1\src\System.Formats.Asn1.csproj" />
</ItemGroup>
</Project>
Loading