(
credentials: MongoCredential, mechanism: str
)
| 238 | |
| 239 | |
| 240 | def _authenticate_scram_start( |
| 241 | credentials: MongoCredential, mechanism: str |
| 242 | ) -> tuple[bytes, bytes, typing.MutableMapping[str, Any]]: |
| 243 | username = credentials.username |
| 244 | user = username.encode("utf-8").replace(b"=", b"=3D").replace(b",", b"=2C") |
| 245 | nonce = standard_b64encode(os.urandom(32)) |
| 246 | first_bare = b"n=" + user + b",r=" + nonce |
| 247 | |
| 248 | cmd = { |
| 249 | "saslStart": 1, |
| 250 | "mechanism": mechanism, |
| 251 | "payload": Binary(b"n,," + first_bare), |
| 252 | "autoAuthorize": 1, |
| 253 | "options": {"skipEmptyExchange": True}, |
| 254 | } |
| 255 | return nonce, first_bare, cmd |
no test coverage detected