bug fix: authentication mongodb

pull/1/head
Steve Nyemba 2 years ago
parent fd9523e99a
commit 899339f11f

@ -8,7 +8,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read() return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = { args = {
"name":"data-transport", "name":"data-transport",
"version":"1.4.10", "version":"1.5.0",
"author":"The Phi Technology LLC","author_email":"info@the-phi.com", "author":"The Phi Technology LLC","author_email":"info@the-phi.com",
"license":"MIT", "license":"MIT",
"packages":["transport"]} "packages":["transport"]}

@ -33,20 +33,24 @@ class Mongo :
:username username for authentication :username username for authentication
:password password for current user :password password for current user
""" """
host = args['host'] if 'host' in args else 'localhost:27017' port = str(args['port']) if 'port' in args else '27017'
host = args['host'] if 'host' in args else 'localhost'
host = ":".join([host,port]) #-- Formatting host information here
self.uid = args['doc'] if 'doc' in args else None #-- document identifier
self.dbname = args['dbname'] if 'dbname' in args else args['db']
self._lock = False if 'lock' not in args else args['lock']
if 'user' in args and 'password' in args: if 'user' in args and 'password' in args:
self.client = MongoClient(host, self.client = MongoClient(host,
username=args['username'] , username=args['username'] ,
password=args['password'] , password=args['password'] ,
authSource=(args['authSource'] if 'authSource' in args else self.dbname),
authMechanism='SCRAM-SHA-256') authMechanism='SCRAM-SHA-256')
else: else:
self.client = MongoClient(host,maxPoolSize=10000) self.client = MongoClient(host,maxPoolSize=10000)
self.uid = args['doc'] #-- document identifier
self.dbname = args['dbname'] if 'dbname' in args else args['db']
self.db = self.client[self.dbname] self.db = self.client[self.dbname]
self._lock = False if 'lock' not in args else args['lock']
def isready(self): def isready(self):
p = self.dbname in self.client.list_database_names() p = self.dbname in self.client.list_database_names()

Loading…
Cancel
Save