From 0f75dfcf9fcbe2aa274cf4b622e5b4599ba9dc8e Mon Sep 17 00:00:00 2001 From: Matt Jackson Date: Tue, 5 May 2015 12:06:09 +0100 Subject: [PATCH 1/3] authenticate using auth source (--authenticationdatabase) when supplied --- django_mongodb_engine/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django_mongodb_engine/base.py b/django_mongodb_engine/base.py index 033008e4..b371a324 100644 --- a/django_mongodb_engine/base.py +++ b/django_mongodb_engine/base.py @@ -264,8 +264,10 @@ def pop(name, default=None): exc_info = sys.exc_info() raise ImproperlyConfigured, exc_info[1], exc_info[2] + auth_source = options.get('authSource') + if user and password: - if not self.database.authenticate(user, password): + if not self.database.authenticate(user, password, source=auth_source): raise ImproperlyConfigured("Invalid username or password.") self.connected = True From 79d2793898bc4b8c81a213327b399155bb62b36a Mon Sep 17 00:00:00 2001 From: Matt Jackson Date: Tue, 5 May 2015 12:17:15 +0100 Subject: [PATCH 2/3] lowercased option --- django_mongodb_engine/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_mongodb_engine/base.py b/django_mongodb_engine/base.py index b371a324..598c701a 100644 --- a/django_mongodb_engine/base.py +++ b/django_mongodb_engine/base.py @@ -264,7 +264,7 @@ def pop(name, default=None): exc_info = sys.exc_info() raise ImproperlyConfigured, exc_info[1], exc_info[2] - auth_source = options.get('authSource') + auth_source = options.get('authsource') if user and password: if not self.database.authenticate(user, password, source=auth_source): From a2ccce21b163d1ef910fd9fb2d42f93cc33a06ad Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Tue, 14 Jul 2015 11:49:07 +0100 Subject: [PATCH 3/3] added authsource to the documentation --- django_mongodb_engine/base.py | 4 +--- docs/source/reference/settings.rst | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/django_mongodb_engine/base.py b/django_mongodb_engine/base.py index ad9de96f..f651d7a7 100644 --- a/django_mongodb_engine/base.py +++ b/django_mongodb_engine/base.py @@ -266,10 +266,8 @@ def pop(name, default=None): exc_info = sys.exc_info() raise ImproperlyConfigured, exc_info[1], exc_info[2] - auth_source = options.get('authsource') - if user and password: - if not self.database.authenticate(user, password, source=auth_source): + if not self.database.authenticate(user, password, source=options.get('authsource')): raise ImproperlyConfigured("Invalid username or password.") self.connected = True diff --git a/docs/source/reference/settings.rst b/docs/source/reference/settings.rst index e23ca372..8de12a18 100644 --- a/docs/source/reference/settings.rst +++ b/docs/source/reference/settings.rst @@ -17,6 +17,7 @@ Additional flags may be passed to :class:`pymongo.Connection` using the 'slave_okay' : True, 'tz_aware' : True, 'network_timeout' : 42, + 'authSource': 'authentication_database_name' ... } }