-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
fix DigestAuth default value for qop field #2600
Conversation
Make the default qop value the same as Chrome, curl and others. Without this some servers will obviously give status 401.
if you will accept this change, I will adjust the tests as well. |
Are you able to show us how to confirm this? Using this command: $ curl -v 'https://jigsaw.w3.org/HTTP/Digest/' --digest -u guest:guest I see the following header... > Authorization: Digest username="guest", realm="test", nonce="e4f988c95c2f85eb3e8501b313f76576", uri="/HTTP/Digest/", response="f8d36a13eaf246e1eb5268c7806a294a"
Are you able to provide an example against a public URL? |
I am not aware of any public URLs as Digest auth isn't so popular anymore. Here is an example: $ curl --digest -u Admin:456 http://192.168.1.141/polling/deviceHandler
<PolycomIPPhone>
<DeviceInformation>
<MACAddress>00907a147020</MACAddress>
<PhoneDN>Line1:2009</PhoneDN>
<AppLoadID>5.0.0.2079 06-Sep-16 08:24</AppLoadID>
<UpdaterID>5.0.0.2079</UpdaterID>
<ModelNumber>Spectralink 8440</ModelNumber>
<TimeStamp>2023-02-23T09:15:51-08:00</TimeStamp>
</DeviceInformation> $ python
>>> import httpx
>>> httpx.get("http://192.168.1.141/polling/deviceHandler", auth=httpx.DigestAuth("Admin", "456"))
<Response [401 Unauthorized]> I also used my JetBrains PyCharm Pro IDE built in HTTP client and it doesn't give 401 either.
I also tried Brave (Chrome) and it brought up a dialog to enter username + password and didn't give 401 either. I can do a Zoom / Teams / Code with Me call with you to show this isn't cheating with the copy and paste. |
@tomchristie any decision on this yet? |
From my reading of https://httpwg.org/specs/rfc7616.html#authorization.request.header.field I think you've got this correct. The RFC states that...
Are you able to show use In any case, yes it looks to me like a more robust behaviour would be treating an omitted It looks like the typing of this...
...would need to be updated, and that we've got a couple of code branches checking |
Here is the command I used:
Here is the output from the command:
CommentsThe above command / operation worked as expected / designed; "Testing" was displayed on the screen of the phone / device. The |
I think this is worth progressing. It looks to me like there's a couple of other changes this will impact... class _DigestAuthChallenge(typing.NamedTuple):
realm: bytes
nonce: bytes
algorithm: str
opaque: typing.Optional[bytes]
qop: typing.Optional[bytes] # <--- no longer optional And... if qop is None:
digest_data = [HA1, challenge.nonce, HA2] # <--- Assume this branch can no longer be followed?
else:
digest_data = [challenge.nonce, nc_value, cnonce, qop, HA2] |
TLDR: This is not the right fix; I believe it's the same issue #3045 solves. Unspecified In short, there are two variants of digest auth - old one from RFC 2069, and a newer one from RFC 2617 (later updated in RFC 7616). The hash in constructed differently depending on which one is being used. Clients can differentiate by the presence of the
Curl's doing the same thing: https://github.com/curl/curl/blob/8edcfedc1a144f438bd1cdf814a0016cbe678aaf/lib/vauth/digest.c#L793-L799 It looks like your SIP phone's using the older variant (2069). RFC 2069 implementation in httpx is currently broken, and #3045 fixes it. |
✨ thanks for getting a handle on this @the-ress. ✨ |
Make the default qop value the same as Chrome, curl and others.
Without this some servers will obviously give status 401.