From 899339f11fb01394f4c36c274427ff13bea7db71 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Fri, 6 May 2022 14:25:12 -0500 Subject: [PATCH] bug fix: authentication mongodb --- setup.py | 2 +- transport/mongo.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index f87db4d..67ecfc4 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() args = { "name":"data-transport", - "version":"1.4.10", + "version":"1.5.0", "author":"The Phi Technology LLC","author_email":"info@the-phi.com", "license":"MIT", "packages":["transport"]} diff --git a/transport/mongo.py b/transport/mongo.py index 1be36a9..fd2c5b8 100644 --- a/transport/mongo.py +++ b/transport/mongo.py @@ -33,20 +33,24 @@ class Mongo : :username username for authentication :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: self.client = MongoClient(host, username=args['username'] , password=args['password'] , + authSource=(args['authSource'] if 'authSource' in args else self.dbname), authMechanism='SCRAM-SHA-256') else: 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._lock = False if 'lock' not in args else args['lock'] def isready(self): p = self.dbname in self.client.list_database_names()