mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-128192: support HTTP sha-256 digest authentication as per RFC-7617 (GH-128193)
support sha-256 digest authentication Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
492b224b99
commit
f9a5a3a3ef
6 changed files with 41 additions and 5 deletions
|
@ -1048,7 +1048,7 @@ _randombytes = os.urandom
|
|||
|
||||
|
||||
class AbstractDigestAuthHandler:
|
||||
# Digest authentication is specified in RFC 2617.
|
||||
# Digest authentication is specified in RFC 2617/7616.
|
||||
|
||||
# XXX The client does not inspect the Authentication-Info header
|
||||
# in a successful response.
|
||||
|
@ -1176,11 +1176,14 @@ class AbstractDigestAuthHandler:
|
|||
return base
|
||||
|
||||
def get_algorithm_impls(self, algorithm):
|
||||
# algorithm names taken from RFC 7616 Section 6.1
|
||||
# lambdas assume digest modules are imported at the top level
|
||||
if algorithm == 'MD5':
|
||||
H = lambda x: hashlib.md5(x.encode("ascii")).hexdigest()
|
||||
elif algorithm == 'SHA':
|
||||
elif algorithm == 'SHA': # non-standard, retained for compatibility.
|
||||
H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest()
|
||||
elif algorithm == 'SHA-256':
|
||||
H = lambda x: hashlib.sha256(x.encode("ascii")).hexdigest()
|
||||
# XXX MD5-sess
|
||||
else:
|
||||
raise ValueError("Unsupported digest authentication "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue