소스 검색

bug fix: authentication mongodb

Steve Nyemba 3 년 전
부모
커밋
899339f11f
2개의 변경된 파일9개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 1
      setup.py
  2. 8 4
      transport/mongo.py

+ 1 - 1
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"]}

+ 8 - 4
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()