diff --git a/src/client/auth/mod.rs b/src/client/auth/mod.rs index 5fe3f0758..4ef0389fa 100644 --- a/src/client/auth/mod.rs +++ b/src/client/auth/mod.rs @@ -205,7 +205,7 @@ impl AuthMechanism { uri_db.unwrap_or("admin") } AuthMechanism::MongoDbX509 => "$external", - AuthMechanism::Plain => "$external", + AuthMechanism::Plain => uri_db.unwrap_or("$external"), #[cfg(feature = "aws-auth")] AuthMechanism::MongoDbAws => "$external", _ => "", @@ -336,7 +336,8 @@ pub struct Credential { pub username: Option, /// The database used to authenticate. This applies to all mechanisms and defaults to "admin" - /// in SCRAM authentication mechanisms and "$external" for GSSAPI, MONGODB-X509 and PLAIN. + /// in SCRAM authentication mechanisms, "$external" for GSSAPI and MONGODB-X509, and the + /// database name or "$external" for PLAIN. pub source: Option, /// The password to authenticate with. This does not apply to all mechanisms. diff --git a/src/test/spec/auth.rs b/src/test/spec/auth.rs index 55e8e1285..61373aa3a 100644 --- a/src/test/spec/auth.rs +++ b/src/test/spec/auth.rs @@ -52,14 +52,12 @@ async fn run_auth_test(test_file: TestFile) { let skipped_mechanisms = [ "GSSAPI", - "PLAIN", "MONGODB-CR", #[cfg(not(feature = "aws-auth"))] "MONGODB-AWS", ]; // TODO: GSSAPI (RUST-196) - // TODO: PLAIN (RUST-992) if skipped_mechanisms .iter() .any(|mech| test_case.description.contains(mech))