@@ -58,6 +58,7 @@ def _get_connection_settings(
5858 password = None ,
5959 authentication_source = None ,
6060 authentication_mechanism = None ,
61+ authmechanismproperties = None ,
6162 ** kwargs ,
6263):
6364 """Get the connection settings as a dict
@@ -88,6 +89,7 @@ def _get_connection_settings(
8889 "password" : password ,
8990 "authentication_source" : authentication_source ,
9091 "authentication_mechanism" : authentication_mechanism ,
92+ "authmechanismproperties" : authmechanismproperties ,
9193 }
9294
9395 _check_db_name (conn_settings ["name" ])
@@ -158,6 +160,10 @@ def _get_connection_settings(
158160 ):
159161 conn_settings ["read_preference" ] = preference
160162 break
163+ if "authmechanismproperties" in uri_options :
164+ conn_settings ["authmechanismproperties" ] = uri_options [
165+ "authmechanismproperties"
166+ ]
161167 else :
162168 resolved_hosts .append (entity )
163169 conn_settings ["host" ] = resolved_hosts
@@ -196,6 +202,7 @@ def register_connection(
196202 password = None ,
197203 authentication_source = None ,
198204 authentication_mechanism = None ,
205+ authmechanismproperties = None ,
199206 ** kwargs ,
200207):
201208 """Register the connection settings.
@@ -228,6 +235,7 @@ def register_connection(
228235 password = password ,
229236 authentication_source = authentication_source ,
230237 authentication_mechanism = authentication_mechanism ,
238+ authmechanismproperties = authmechanismproperties ,
231239 ** kwargs ,
232240 )
233241 _connection_settings [alias ] = conn_settings
@@ -289,6 +297,7 @@ def _clean_settings(settings_dict):
289297 "password" ,
290298 "authentication_source" ,
291299 "authentication_mechanism" ,
300+ "authmechanismproperties" ,
292301 }
293302 rename_fields = {}
294303 else :
@@ -388,6 +397,7 @@ def get_db(alias=DEFAULT_CONNECTION_NAME, reconnect=False):
388397 conn_settings ["password" ]
389398 or conn_settings ["authentication_mechanism" ] == "MONGODB-X509"
390399 )
400+ and conn_settings ["authmechanismproperties" ] is None
391401 ):
392402 auth_kwargs = {"source" : conn_settings ["authentication_source" ]}
393403 if conn_settings ["authentication_mechanism" ] is not None :
0 commit comments