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

accept empty realm for digest auth (#56369) #56455

Merged
merged 5 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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