Skip to content

Commit 13d8aba

Browse files
committed
Remove $external from the public API PYTHON-465
1 parent c758efc commit 13d8aba

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

pymongo/database.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@ def _check_name(name):
3434
if not name:
3535
raise InvalidName("database name cannot be the empty string")
3636

37-
# '$' is an illegal character in database names but $external
38-
# is required for GSSAPI authentication.
39-
if name != '$external':
40-
for invalid_char in [" ", ".", "$", "/", "\\", "\x00"]:
41-
if invalid_char in name:
42-
raise InvalidName("database names cannot contain the "
43-
"character %r" % invalid_char)
37+
for invalid_char in [" ", ".", "$", "/", "\\", "\x00"]:
38+
if invalid_char in name:
39+
raise InvalidName("database names cannot contain the "
40+
"character %r" % invalid_char)
4441

4542

4643
class Database(common.BaseObject):

pymongo/mongo_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,11 @@ def __init__(self, host=None, port=None, max_pool_size=10,
280280
source = '$external'
281281
else:
282282
source = db_name or 'admin'
283-
if not self[source].authenticate(username,
284-
password, source, mechanism):
283+
credentials = (source, unicode(username),
284+
unicode(password), mechanism)
285+
try:
286+
self._cache_credentials(source, credentials)
287+
except OperationFailure:
285288
raise ConfigurationError("authentication failed")
286289

287290
def _cached(self, dbname, coll, index):

pymongo/mongo_replica_set_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,13 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
470470
source = '$external'
471471
else:
472472
source = db_name or 'admin'
473-
if not self[source].authenticate(username,
474-
password, source, mechanism):
473+
credentials = (source, unicode(username),
474+
unicode(password), mechanism)
475+
try:
476+
self._cache_credentials(source, credentials)
477+
except OperationFailure:
475478
raise ConfigurationError("authentication failed")
476479

477-
478480
# Start the monitor after we know the configuration is correct.
479481
if monitor_class:
480482
self.__monitor = monitor_class(self)

0 commit comments

Comments
 (0)