summaryrefslogtreecommitdiff
path: root/src/mongo/shell/dbshell.cpp
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2019-01-22 17:41:00 +0000
committerSara Golemon <sara.golemon@mongodb.com>2019-01-26 02:20:22 +0000
commit82e05d6c201fa59223aa40340a5d4ad84b32ac65 (patch)
tree56946c4531bb45be3d0e37f5a92f1692efb4288c /src/mongo/shell/dbshell.cpp
parent7f23fe72f78d2ec6ac84cbb75ac8a6bcce977e82 (diff)
downloadmongo-82e05d6c201fa59223aa40340a5d4ad84b32ac65.tar.gz
SERVER-39128 Avoid double-authentication
Diffstat (limited to 'src/mongo/shell/dbshell.cpp')
-rw-r--r--src/mongo/shell/dbshell.cpp51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 47018c07c06..32194e95839 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -832,57 +832,6 @@ int _main(int argc, char* argv[], char** envp) {
mongo::shell_utils::_dbConnect = ss.str();
}
- // Construct the authentication-related code to execute on shell startup.
- //
- // This constructs and immediately executes an anonymous function, to avoid
- // the shell's default behavior of printing statement results to the console.
- //
- // It constructs a statement of the following form:
- //
- // (function() {
- // // Set default authentication mechanism and, maybe, authenticate.
- // }())
- stringstream authStringStream;
- authStringStream << "(function() { " << endl;
-
-
- if (const auto authMechanisms = parsedURI.getOption("authMechanism")) {
- authStringStream << "DB.prototype._defaultAuthenticationMechanism = \""
- << escape(authMechanisms.get()) << "\";" << endl;
- }
-
- if (const auto gssapiServiveName = parsedURI.getOption("gssapiServiceName")) {
- authStringStream << "DB.prototype._defaultGssapiServiceName = \""
- << escape(gssapiServiveName.get()) << "\";" << endl;
- }
-
- if (!shellGlobalParams.nodb &&
- (!parsedURI.getUser().empty() ||
- parsedURI.getOption("authMechanism").get_value_or("") == "MONGODB-X509")) {
- authStringStream << "var username = \"" << escape(parsedURI.getUser()) << "\";" << endl;
- if (usingPassword) {
- authStringStream << "var password = \"" << escape(parsedURI.getPassword()) << "\";"
- << endl;
- }
- authStringStream << "var authDb = db.getSiblingDB(\""
- << escape(parsedURI.getAuthenticationDatabase()) << "\");" << endl;
-
- authStringStream << "authDb._authOrThrow({ ";
- if (!parsedURI.getUser().empty()) {
- authStringStream << saslCommandUserFieldName << ": username ";
- }
- if (usingPassword) {
- authStringStream << ", " << saslCommandPasswordFieldName << ": password ";
- }
- if (const auto gssapiHostNameKey = parsedURI.getOption("gssapiHostName")) {
- authStringStream << ", " << saslCommandServiceHostnameFieldName << ": \""
- << escape(gssapiHostNameKey.get()) << '"' << endl;
- }
- authStringStream << "});" << endl;
- }
- authStringStream << "}())";
- mongo::shell_utils::_dbAuth = authStringStream.str();
-
mongo::ScriptEngine::setConnectCallback(mongo::shell_utils::onConnect);
mongo::ScriptEngine::setup();
mongo::getGlobalScriptEngine()->setJSHeapLimitMB(shellGlobalParams.jsHeapLimitMB);