summaryrefslogtreecommitdiff
path: root/src/mongo/shell
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
parent7f23fe72f78d2ec6ac84cbb75ac8a6bcce977e82 (diff)
downloadmongo-82e05d6c201fa59223aa40340a5d4ad84b32ac65.tar.gz
SERVER-39128 Avoid double-authentication
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/dbshell.cpp51
-rw-r--r--src/mongo/shell/shell_utils.cpp4
-rw-r--r--src/mongo/shell/shell_utils.h1
3 files changed, 0 insertions, 56 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);
diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp
index e44832d9e35..7f8521c6058 100644
--- a/src/mongo/shell/shell_utils.cpp
+++ b/src/mongo/shell/shell_utils.cpp
@@ -78,7 +78,6 @@ MONGO_REGISTER_SHIM(BenchRunConfig::createConnectionImpl)
namespace shell_utils {
std::string _dbConnect;
-std::string _dbAuth;
const char* argv0 = 0;
void RecordMyLocation(const char* _argv0) {
@@ -349,9 +348,6 @@ void initScope(Scope& scope) {
if (!_dbConnect.empty()) {
uassert(12513, "connect failed", scope.exec(_dbConnect, "(connect)", false, true, false));
}
- if (!_dbAuth.empty()) {
- uassert(12514, "login failed", scope.exec(_dbAuth, "(auth)", true, true, false));
- }
}
Prompter::Prompter(const string& prompt) : _prompt(prompt), _confirmed() {}
diff --git a/src/mongo/shell/shell_utils.h b/src/mongo/shell/shell_utils.h
index 14878bfed5c..0d32c02917e 100644
--- a/src/mongo/shell/shell_utils.h
+++ b/src/mongo/shell/shell_utils.h
@@ -43,7 +43,6 @@ class DBClientBase;
namespace shell_utils {
extern std::string _dbConnect;
-extern std::string _dbAuth;
void RecordMyLocation(const char* _argv0);
void installShellUtils(Scope& scope);