Add support for using an authentication database for MongoDB.
A popular convention is to have user accounts stored in a separate authentication database. This change add support for configuring edx-platform to work with such a setup.
This commit is contained in:
@@ -29,6 +29,7 @@ class MongoBackend(BaseBackend):
|
||||
- `password`: collection user password
|
||||
- `database`: name of the database
|
||||
- `collection`: name of the collection
|
||||
- 'auth_source': name of the authentication database
|
||||
- `extra`: parameters to pymongo.MongoClient not listed above
|
||||
|
||||
"""
|
||||
@@ -46,6 +47,8 @@ class MongoBackend(BaseBackend):
|
||||
db_name = kwargs.get('database', 'track')
|
||||
collection_name = kwargs.get('collection', 'events')
|
||||
|
||||
auth_source = kwargs.get('auth_source') or None
|
||||
|
||||
# Other mongo connection arguments
|
||||
extra = kwargs.get('extra', {})
|
||||
|
||||
@@ -67,7 +70,7 @@ class MongoBackend(BaseBackend):
|
||||
database = self.connection[db_name]
|
||||
|
||||
if user or password:
|
||||
database.authenticate(user, password)
|
||||
database.authenticate(user, password, source=auth_source)
|
||||
|
||||
self.collection = database[collection_name]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user