Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -99,6 +99,7 @@ public static IEnumerable<object[]> Authentication_SocketsHttpHandler_TestData()
{
yield return new object[] { "Digest realm=\"testrealm\",nonce=\"6afd170437eb5144258b308f7c491d96\",opaque=\"\",stale=FALSE,algorithm=MD5,qop=\"auth\"", true };
yield return new object[] { "Digest realm=\"testrealm\", domain=\"\", nonce=\"NA42+vpOFQd1GwCyVRZuhhy+jDn4BMRl\", algorithm=MD5, qop=\"auth\", stale=false", true };
yield return new object[] { "Digest realm=\"\", nonce=\"NA42+vpOFQd1GwCyVRZuhhy+jDn4BMRl\", algorithm=MD5, qop=\"auth\", stale=false", true };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ internal static bool IsDigestAuthTokenValid(string clientResponse, string reques
}

// Realm is mandatory.
if (string.IsNullOrEmpty(realm))
if (realm == null)
return false;
}
else if (trimmedValue.StartsWith(nameof(cnonce)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ internal static partial class AuthenticationHelper
}

// Add realm
if (realm != string.Empty)
sb.AppendKeyValue(Realm, realm);
sb.AppendKeyValue(Realm, realm);

// Add nonce
sb.AppendKeyValue(Nonce, nonce);
Expand Down Expand Up @@ -407,9 +406,11 @@ private void Parse(string challenge)
break;

// Ensure value is valid.
// Opaque and Domain can have empty string
// Opaque, Domain and Realm can have empty string
if (value == string.Empty &&
(!key.Equals(Opaque, StringComparison.OrdinalIgnoreCase) && !key.Equals(Domain, StringComparison.OrdinalIgnoreCase)))
!key.Equals(Opaque, StringComparison.OrdinalIgnoreCase) &&
!key.Equals(Domain, StringComparison.OrdinalIgnoreCase) &&
!key.Equals(Realm, StringComparison.OrdinalIgnoreCase))
break;

// Add the key-value pair to Parameters.
Expand Down