DigestAuth not working #2392
Replies: 2 comments
-
Hiya! I'm going to bump this over into a discussion, until we've confirmed if there's an issue here or not. Are you able to replicate this against a publicly accessible URL? Eg. https://httpbin.org/ provides a digest auth endpoint we could use? It'd be really helpful if our command-line client supported digest auth so we could easily compare def trace(event_name, info):
print(event_name, info)
httpx.get(
"http://192.168.12.26/polling/deviceHandler",
auth=httpx.DigestAuth("httpx", "test"),
extensions={"trace": trace}
) And also show us the output from |
Beta Was this translation helpful? Give feedback.
-
We are nearly 2 years and this discussion appears stalled. DigestAuth isn't as popular as it once was so finding a public website may prove to be difficult. I created this issue while trying to work with some older Spectralink handsets (widely used in healthcare setting for alert notification). Is the larger issue here compatibility or specification compliance? curl works and is perhaps a reasonable target for compatibility. Below is the one line change I have been using while this issue / discussion is ongoing. class DigestAuth(_DigestAuth):
"""identical to upstream except default value for qop is now auth instead of None."""
def _parse_challenge(self, request: Request, response: Response, auth_header: str) -> "_DigestAuthChallenge":
scheme, _, fields = auth_header.partition(" ")
assert scheme.lower() == "digest"
header_dict: dict[str, str] = {}
for field in parse_http_list(fields):
key, value = field.strip().split("=", 1)
header_dict[key] = unquote(value)
try:
realm = header_dict["realm"].encode()
nonce = header_dict["nonce"].encode()
algorithm = header_dict.get("algorithm", "MD5")
opaque = header_dict["opaque"].encode() if "opaque" in header_dict else None
qop = header_dict["qop"].encode() if "qop" in header_dict else b"auth" # changed here
return _DigestAuthChallenge(realm=realm, nonce=nonce, algorithm=algorithm, opaque=opaque, qop=qop)
except KeyError as exc:
message = "Malformed Digest WWW-Authenticate header"
raise ProtocolError(message, request=request) from exc |
Beta Was this translation helpful? Give feedback.
-
Not Working
Working
curl --digest -u 'httpx:test' http://192.168.12.26/polling/deviceHandler
or
output
If unable to reproduce and you'd like me to put in some breakpoints / capture some context / state please let me know.
Beta Was this translation helpful? Give feedback.
All reactions