HTTPDigestAuth uses quotes for algorithm and qop tokens of the Digest header
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 54.3k
- Forks
- 10.4k
- Avg merge
- 16h 43m
- Merged PRs (30d)
- 3
Description
The HTTPDigestAuth.build_digest_header() method produces the Digest header witch contains quoted strings for algorithm and qop tokens. E.g.:
Digest username="admin", realm="server", nonce="QScBItGtnPq4Dz3v25Tht4SlctJnsR", uri="/api/v1/info", response="e0d12a4b85789351a847c773e6f4b30e", algorithm="MD5", qop="auth", nc=00000001, cnonce="0f905170a2cafe15"
While according to RFC 7616 these tokens must not be quoted:
Digest username="admin", realm="server", nonce="QScBItGtnPq4Dz3v25Tht4SlctJnsR", uri="/api/v1/info", response="e0d12a4b85789351a847c773e6f4b30e", algorithm=MD5, qop=auth, nc=00000001, cnonce="0f905170a2cafe15"
Below is the corresponding part of the RFC:
For historical reasons, a sender MUST only generate the quoted string syntax for the following parameters: username, realm, nonce, uri, response, cnonce, and opaque.
For historical reasons, a sender MUST NOT generate the quoted string syntax for the following parameters: algorithm, qop, and nc.
This can also be seen in requests examples in the RFC.
Current behavior may cause problems with some servers. The following subclass can be used as a temporary workaround:
class FixedHTTPDigestAuth(HTTPDigestAuth):
def build_digest_header(self, method, url):
header = super().build_digest_header(method, url)
invalid_parts = ('algorithm', 'qop')
parts = header.split(', ')
for i, part in enumerate(parts):
if any(part.startswith(ip + '=') for ip in invalid_parts):
parts[i] = part.replace('"', '')
header = ', '.join(parts)
return header
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the HTTPDigestAuth.build_digest_header() method and compare its generated Digest header with the RFC 7616 examples cited in the issue. Done means algorithm and qop use unquoted tokens while the other parameters retain the required quoting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100