MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _authenticate_default

Function _authenticate_default

pymongo/synchronous/auth.py:343–357  ·  view source on GitHub ↗
(credentials: MongoCredential, conn: Connection)

Source from the content-addressed store, hash-verified

341
342
343def _authenticate_default(credentials: MongoCredential, conn: Connection) -> None:
344 if conn.max_wire_version >= 7:
345 if conn.negotiated_mechs:
346 mechs = conn.negotiated_mechs
347 else:
348 source = credentials.source
349 cmd = conn.hello_cmd()
350 cmd["saslSupportedMechs"] = source + "." + credentials.username
351 mechs = (conn.command(source, cmd, publish_events=False)).get("saslSupportedMechs", [])
352 if "SCRAM-SHA-256" in mechs:
353 return _authenticate_scram(credentials, conn, "SCRAM-SHA-256")
354 else:
355 return _authenticate_scram(credentials, conn, "SCRAM-SHA-1")
356 else:
357 return _authenticate_scram(credentials, conn, "SCRAM-SHA-1")
358
359
360_AUTH_MAP: Mapping[str, Callable[..., None]] = {

Callers

nothing calls this directly

Calls 4

_authenticate_scramFunction · 0.70
hello_cmdMethod · 0.45
getMethod · 0.45
commandMethod · 0.45

Tested by

no test coverage detected