-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
PYTHON-4922 Remove Support for MONGODB-CR Authentication #1978
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,24 +76,6 @@ For best performance on Python versions older than 2.7.8 install `backports.pbkd | |
|
||
.. _backports.pbkdf2: https://pypi.python.org/pypi/backports.pbkdf2/ | ||
|
||
MONGODB-CR | ||
---------- | ||
|
||
.. warning:: MONGODB-CR was deprecated with the release of MongoDB 3.6 and | ||
is no longer supported by MongoDB 4.0. | ||
|
||
Before MongoDB 3.0 the default authentication mechanism was MONGODB-CR, | ||
the "MongoDB Challenge-Response" protocol:: | ||
|
||
>>> from pymongo import MongoClient | ||
>>> client = MongoClient('example.com', | ||
... username='user', | ||
... password='password', | ||
... authMechanism='MONGODB-CR') | ||
>>> | ||
>>> uri = "mongodb://user:[email protected]/?authSource=the_database&authMechanism=MONGODB-CR" | ||
>>> client = MongoClient(uri) | ||
|
||
Default Authentication Mechanism | ||
-------------------------------- | ||
|
||
|
@@ -221,8 +203,7 @@ SASL PLAIN (RFC 4616) | |
|
||
MongoDB Enterprise Edition version 2.6 and newer support the SASL PLAIN | ||
authentication mechanism, initially intended for delegating authentication | ||
to an LDAP server. Using the PLAIN mechanism is very similar to MONGODB-CR. | ||
These examples use the $external virtual database for LDAP support:: | ||
to an LDAP server. These examples use the $external virtual database for LDAP support:: | ||
|
||
>>> from pymongo import MongoClient | ||
>>> uri = "mongodb://user:[email protected]/?authMechanism=PLAIN" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,6 @@ | |
MECHANISMS = frozenset( | ||
[ | ||
"GSSAPI", | ||
"MONGODB-CR", | ||
"MONGODB-OIDC", | ||
"MONGODB-X509", | ||
"MONGODB-AWS", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,29 +220,8 @@ | |
"options": null | ||
}, | ||
{ | ||
"description": "Escaped user info and database (MONGODB-CR)", | ||
"uri": "mongodb://%24am:f%3Azzb%40z%2Fz%[email protected]/admin%3F?authMechanism=MONGODB-CR", | ||
"valid": true, | ||
"warning": false, | ||
"hosts": [ | ||
{ | ||
"type": "ipv4", | ||
"host": "127.0.0.1", | ||
"port": null | ||
} | ||
], | ||
"auth": { | ||
"username": "$am", | ||
"password": "f:zzb@z/z=", | ||
"db": "admin?" | ||
}, | ||
"options": { | ||
"authmechanism": "MONGODB-CR" | ||
} | ||
}, | ||
{ | ||
"description": "Subdelimiters in user/pass don't need escaping (MONGODB-CR)", | ||
"uri": "mongodb://!$&'()*+,;=:!$&'()*+,;[email protected]/admin?authMechanism=MONGODB-CR", | ||
"description": "Subdelimiters in user/pass don't need escaping (PLAIN)", | ||
"uri": "mongodb://!$&'()*+,;=:!$&'()*+,;[email protected]/admin?authMechanism=PLAIN", | ||
"valid": true, | ||
"warning": false, | ||
"hosts": [ | ||
|
@@ -258,7 +237,7 @@ | |
"db": "admin" | ||
}, | ||
"options": { | ||
"authmechanism": "MONGODB-CR" | ||
"authmechanism": "PLAIN" | ||
} | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"tests": [ | ||
{ | ||
"description": "Option names are normalized to lowercase", | ||
"uri": "mongodb://alice:[email protected]/admin?AUTHMechanism=MONGODB-CR", | ||
"uri": "mongodb://alice:[email protected]/admin?AUTHMechanism=PLAIN", | ||
"valid": true, | ||
"warning": false, | ||
"hosts": [ | ||
|
@@ -18,7 +18,7 @@ | |
"db": "admin" | ||
}, | ||
"options": { | ||
"authmechanism": "MONGODB-CR" | ||
"authmechanism": "PLAIN" | ||
} | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,6 @@ def test_split_options(self): | |
self.assertEqual({"fsync": True}, split_options("fsync=true")) | ||
self.assertEqual({"fsync": False}, split_options("fsync=false")) | ||
self.assertEqual({"authmechanism": "GSSAPI"}, split_options("authMechanism=GSSAPI")) | ||
self.assertEqual({"authmechanism": "MONGODB-CR"}, split_options("authMechanism=MONGODB-CR")) | ||
self.assertEqual( | ||
{"authmechanism": "SCRAM-SHA-1"}, split_options("authMechanism=SCRAM-SHA-1") | ||
) | ||
|
@@ -295,30 +294,30 @@ def test_parse_uri(self): | |
|
||
# Various authentication tests | ||
res = copy.deepcopy(orig) | ||
res["options"] = {"authmechanism": "MONGODB-CR"} | ||
res["options"] = {"authmechanism": "SCRAM-SHA-256"} | ||
res["username"] = "user" | ||
res["password"] = "password" | ||
self.assertEqual( | ||
res, parse_uri("mongodb://user:password@localhost/?authMechanism=MONGODB-CR") | ||
res, parse_uri("mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-256") | ||
) | ||
|
||
res = copy.deepcopy(orig) | ||
res["options"] = {"authmechanism": "MONGODB-CR", "authsource": "bar"} | ||
res["options"] = {"authmechanism": "SCRAM-SHA-256", "authsource": "bar"} | ||
res["username"] = "user" | ||
res["password"] = "password" | ||
res["database"] = "foo" | ||
self.assertEqual( | ||
res, | ||
parse_uri( | ||
"mongodb://user:password@localhost/foo?authSource=bar;authMechanism=MONGODB-CR" | ||
"mongodb://user:password@localhost/foo?authSource=bar;authMechanism=SCRAM-SHA-256" | ||
), | ||
) | ||
|
||
res = copy.deepcopy(orig) | ||
res["options"] = {"authmechanism": "MONGODB-CR"} | ||
res["options"] = {"authmechanism": "SCRAM-SHA-256"} | ||
res["username"] = "user" | ||
res["password"] = "" | ||
self.assertEqual(res, parse_uri("mongodb://user:@localhost/?authMechanism=MONGODB-CR")) | ||
self.assertEqual(res, parse_uri("mongodb://user:@localhost/?authMechanism=SCRAM-SHA-256")) | ||
|
||
res = copy.deepcopy(orig) | ||
res["username"] = "[email protected]" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Rather than removing these tests, can you update then to use SCRAM-SHA-256?
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.
Done