diff options
author | Hai-Kinh Hoang <haikinh.hoang@mongodb.com> | 2016-08-10 10:57:32 -0400 |
---|---|---|
committer | Hai-Kinh Hoang <haikinh.hoang@mongodb.com> | 2016-08-17 14:54:58 -0400 |
commit | c267c7ad3573c82e9b463cc6f918e76bb921b292 (patch) | |
tree | 845209245734ed585b90a97735ca9e6f3301c403 /src/mongo/shell | |
parent | 7f05ff5fd7fab804d8d84397714b308adec6fe1a (diff) | |
download | mongo-c267c7ad3573c82e9b463cc6f918e76bb921b292.tar.gz |
SERVER-25082 Allow x509 authentication without user/subject field
Diffstat (limited to 'src/mongo/shell')
-rw-r--r-- | src/mongo/shell/dbshell.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp index 97f80abeb5e..243bdd187ef 100644 --- a/src/mongo/shell/dbshell.cpp +++ b/src/mongo/shell/dbshell.cpp @@ -647,7 +647,8 @@ int _main(int argc, char* argv[], char** envp) { << escape(shellGlobalParams.gssapiServiceName) << "\";" << endl; } - if (!shellGlobalParams.nodb && shellGlobalParams.username.size()) { + if (!shellGlobalParams.nodb && (!shellGlobalParams.username.empty() || + shellGlobalParams.authenticationMechanism == "MONGODB-X509")) { authStringStream << "var username = \"" << escape(shellGlobalParams.username) << "\";" << endl; if (shellGlobalParams.usingPassword) { @@ -660,11 +661,14 @@ int _main(int argc, char* argv[], char** envp) { authStringStream << "var authDb = db.getSiblingDB(\"" << escape(shellGlobalParams.authenticationDatabase) << "\");" << endl; } - authStringStream << "authDb._authOrThrow({ " << saslCommandUserFieldName << ": username "; + + authStringStream << "authDb._authOrThrow({ "; + if (!shellGlobalParams.username.empty()) { + authStringStream << saslCommandUserFieldName << ": username "; + } if (shellGlobalParams.usingPassword) { authStringStream << ", " << saslCommandPasswordFieldName << ": password "; } - if (!shellGlobalParams.gssapiHostName.empty()) { authStringStream << ", " << saslCommandServiceHostnameFieldName << ": \"" << escape(shellGlobalParams.gssapiHostName) << '"' << endl; |