Skip to content

Commit

Permalink
Merge 1bd192a into 49cd126
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamikdev committed Jul 20, 2016
2 parents 49cd126 + 1bd192a commit 06f7f5b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions txmongo/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,16 @@ def authenticate_scram_sha1(self, database_name, username, password):
if not result["done"]:
raise MongoAuthenticationError("TxMongo: SASL conversation failed to complete.")

@defer.inlineCallbacks
def authenticate_mongo_x509(self, database_name, username, password):
query = SON([('authenticate', 1),
('mechanism', 'MONGODB-X509'),
('user', username)])
result = yield self.__run_command('$external', query)
if not result["ok"]:
raise MongoAuthenticationError(result["errmsg"])
defer.returnValue(result)

@defer.inlineCallbacks
def authenticate(self, database_name, username, password, mechanism):
database_name = str(database_name)
Expand All @@ -506,6 +516,8 @@ def authenticate(self, database_name, username, password, mechanism):
auth_func = self.authenticate_mongo_cr
elif mechanism == "SCRAM-SHA-1":
auth_func = self.authenticate_scram_sha1
elif mechanism == "MONGODB-X509":
auth_func = self.authenticate_mongo_x509
elif mechanism == "DEFAULT":
if self.max_wire_version >= 3:
auth_func = self.authenticate_scram_sha1
Expand Down

0 comments on commit 06f7f5b

Please sign in to comment.