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

Use managed ntlm on linux-bionic #95274

Merged
merged 8 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ internal partial class NegotiateAuthenticationPal
private static bool UseManagedNtlm { get; } =
AppContext.TryGetSwitch("System.Net.Security.UseManagedNtlm", out bool useManagedNtlm) ?
useManagedNtlm :
OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst();
OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst() ||
(OperatingSystem.IsLinux() && RuntimeInformation.RuntimeIdentifier.StartsWith("linux-bionic", StringComparison.OrdinalIgnoreCase));
rzikm marked this conversation as resolved.
Show resolved Hide resolved
rzikm marked this conversation as resolved.
Show resolved Hide resolved

public static NegotiateAuthenticationPal Create(NegotiateAuthenticationClientOptions clientOptions)
{
Expand Down Expand Up @@ -559,7 +560,8 @@ private NegotiateAuthenticationStatusCode InitializeSecurityContext(
{
if (NetEventSource.Log.IsEnabled())
{
string protocol = _packageType switch {
string protocol = _packageType switch
{
Interop.NetSecurityNative.PackageType.NTLM => "NTLM",
Interop.NetSecurityNative.PackageType.Kerberos => "Kerberos",
_ => "SPNEGO"
Expand Down Expand Up @@ -635,7 +637,8 @@ private NegotiateAuthenticationStatusCode InitializeSecurityContext(
{
if (NetEventSource.Log.IsEnabled())
{
string protocol = _packageType switch {
string protocol = _packageType switch
{
Interop.NetSecurityNative.PackageType.NTLM => "NTLM",
Interop.NetSecurityNative.PackageType.Kerberos => "Kerberos",
_ => isNtlmUsed ? "SPNEGO-NTLM" : "SPNEGO-Kerberos"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public void Constructor_Overloads_Validation()
}

[Fact]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93104")]
public void RemoteIdentity_ThrowsOnUnauthenticated()
{
NegotiateAuthenticationClientOptions clientOptions = new NegotiateAuthenticationClientOptions { Credential = s_testCredentialRight, TargetName = "HTTP/foo" };
Expand Down Expand Up @@ -66,7 +65,6 @@ public void RemoteIdentity_ThrowsOnDisposed()
}

[Fact]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93104")]
public void Package_Unsupported()
{
NegotiateAuthenticationClientOptions clientOptions = new NegotiateAuthenticationClientOptions { Package = "INVALID", Credential = s_testCredentialRight, TargetName = "HTTP/foo" };
Expand Down Expand Up @@ -98,7 +96,6 @@ public void Package_Unsupported_NTLM()

[Fact]
[SkipOnPlatform(TestPlatforms.Windows, "The test is specific to GSSAPI / Managed implementations of NegotiateAuthentication")]
[SkipOnPlatform(TestPlatforms.LinuxBionic, "https://github.com/dotnet/runtime/issues/93104")]
public void DefaultNetworkCredentials_NTLM_DoesNotThrow()
{
NegotiateAuthenticationClientOptions clientOptions = new NegotiateAuthenticationClientOptions { Package = "NTLM", Credential = CredentialCache.DefaultNetworkCredentials, TargetName = "HTTP/foo" };
Expand Down Expand Up @@ -169,7 +166,7 @@ public static IEnumerable<object[]> TestCredentials()
yield return new object[] { new NetworkCredential("rightusername", "rightpassword") };
yield return new object[] { new NetworkCredential("rightusername", "rightpassword", "rightdomain") };
yield return new object[] { new NetworkCredential("rightusername@rightdomain.com", "rightpassword") };
}
}

[ConditionalTheory(nameof(IsNtlmAvailable))]
[MemberData(nameof(TestCredentials))]
Expand Down
Loading