-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-128192: support sha-256 digest authentication #128193
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1182,6 +1182,8 @@ def get_algorithm_impls(self, algorithm): | |
elif algorithm == 'SHA': | ||
H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest() | ||
# XXX MD5-sess | ||
elif algorithm == 'SHA-256': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you move the |
||
H = lambda x: hashlib.sha256(x.encode("ascii")).hexdigest() | ||
else: | ||
raise ValueError("Unsupported digest authentication " | ||
"algorithm %r" % algorithm) | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1 @@ | ||||||||
Support digest authentication algorithm SHA-256 in :mod:`urllib.request`. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This also requires a What's New entry. However, we do not have any documentation concerning HTTP digest access authentication (we only have https://docs.python.org/3/library/urllib.request.html#abstractdigestauthhandler-objects but never do we mention which digests we are supporting). Nonetheless, maybe we can update the wording of that documented entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine, but you should add a test.
from RFC-7616
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont know, I assume i would just be re-writing a test that probably exists in hashlib?
i've only found a single test written for this function that checks for an invalid algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashlib
does not need to be tested. What needs to be tested is thatMD5
,SHA
andSHA-256
are recognized algorithms if you specify them as is in the request headers. This is an opportunity to add tests for this as well.