Skip to content

Commit 89f41cf

Browse files
authored
PYTHON-2999 Remove unused and internal only CRAM-MD5 auth mechanism (#777)
1 parent b342990 commit 89f41cf

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

pymongo/auth.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -421,31 +421,6 @@ def _authenticate_plain(credentials, sock_info):
421421
sock_info.command(source, cmd)
422422

423423

424-
def _authenticate_cram_md5(credentials, sock_info):
425-
"""Authenticate using CRAM-MD5 (RFC 2195)
426-
"""
427-
source = credentials.source
428-
username = credentials.username
429-
password = credentials.password
430-
# The password used as the mac key is the
431-
# same as what we use for MONGODB-CR
432-
passwd = _password_digest(username, password)
433-
cmd = SON([('saslStart', 1),
434-
('mechanism', 'CRAM-MD5'),
435-
('payload', Binary(b'')),
436-
('autoAuthorize', 1)])
437-
response = sock_info.command(source, cmd)
438-
# MD5 as implicit default digest for digestmod is deprecated
439-
# in python 3.4
440-
mac = hmac.HMAC(key=passwd.encode('utf-8'), digestmod=hashlib.md5)
441-
mac.update(response['payload'])
442-
challenge = username.encode('utf-8') + b' ' + mac.hexdigest().encode('utf-8')
443-
cmd = SON([('saslContinue', 1),
444-
('conversationId', response['conversationId']),
445-
('payload', Binary(challenge))])
446-
sock_info.command(source, cmd)
447-
448-
449424
def _authenticate_x509(credentials, sock_info):
450425
"""Authenticate using MONGODB-X509.
451426
"""
@@ -497,7 +472,6 @@ def _authenticate_default(credentials, sock_info):
497472

498473

499474
_AUTH_MAP = {
500-
'CRAM-MD5': _authenticate_cram_md5,
501475
'GSSAPI': _authenticate_gssapi,
502476
'MONGODB-CR': _authenticate_mongo_cr,
503477
'MONGODB-X509': _authenticate_x509,

pymongo/common.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,7 @@ def validate_read_preference_mode(dummy, value):
372372
def validate_auth_mechanism(option, value):
373373
"""Validate the authMechanism URI option.
374374
"""
375-
# CRAM-MD5 is for server testing only. Undocumented,
376-
# unsupported, may be removed at any time. You have
377-
# been warned.
378-
if value not in MECHANISMS and value != 'CRAM-MD5':
375+
if value not in MECHANISMS:
379376
raise ValueError("%s must be in %s" % (option, tuple(MECHANISMS)))
380377
return value
381378

0 commit comments

Comments
 (0)