summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shell_options.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2014-02-27 15:34:46 -0500
committerAndy Schwerin <schwerin@10gen.com>2014-02-28 11:39:58 -0500
commit944807590b5d7a6a5b7b53f02bd032faf9406507 (patch)
tree23d2ce9f21dd483fba311d390194b1d155b3fe65 /src/mongo/shell/shell_options.cpp
parent7851431d5b4b1dc0a5df17c1f7964d2bfc3ff623 (diff)
downloadmongo-944807590b5d7a6a5b7b53f02bd032faf9406507.tar.gz
SERVER-11770 Support changing the default gssapiServiceName from the shell command line.
This patch allows the user to specify an alternate gssapiServiceName (default is mongodb) when authenticating using GSSAPI/Kerberos. It also allows the user to specify the host name to use for authentication purposes, when this does not match the DNS host name. Both of these functions were previously exposed only through the db.auth() method, and not for command-line authentication.
Diffstat (limited to 'src/mongo/shell/shell_options.cpp')
-rw-r--r--src/mongo/shell/shell_options.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 2832989ffe3..906b0b8a106 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -32,6 +32,7 @@
#include "mongo/base/status.h"
#include "mongo/bson/util/builder.h"
+#include "mongo/client/sasl_client_authenticate.h"
#include "mongo/db/server_options.h"
#include "mongo/shell/shell_utils.h"
#include "mongo/util/mongoutils/str.h"
@@ -63,21 +64,33 @@ namespace mongo {
options->addOptionChaining("eval", "eval", moe::String, "evaluate javascript");
- options->addOptionChaining("username", "username,u", moe::String,
+ moe::OptionSection authenticationOptions("Authentication Options");
+
+ authenticationOptions.addOptionChaining("username", "username,u", moe::String,
"username for authentication");
- options->addOptionChaining("password", "password,p", moe::String,
+ authenticationOptions.addOptionChaining("password", "password,p", moe::String,
"password for authentication")
.setImplicit(moe::Value(std::string("")));
- options->addOptionChaining("authenticationDatabase", "authenticationDatabase", moe::String,
- "user source (defaults to dbname)")
+ authenticationOptions.addOptionChaining("authenticationDatabase", "authenticationDatabase",
+ moe::String, "user source (defaults to dbname)")
.setDefault(moe::Value(std::string("")));
- options->addOptionChaining("authenticationMechanism", "authenticationMechanism",
- moe::String, "authentication mechanism")
+ authenticationOptions.addOptionChaining("authenticationMechanism",
+ "authenticationMechanism", moe::String, "authentication mechanism")
.setDefault(moe::Value(std::string("MONGODB-CR")));
+ authenticationOptions.addOptionChaining("gssapiServiceName", "gssapiServiceName",
+ moe::String,
+ "Service name to use when authenticating using GSSAPI/Kerberos")
+ .setDefault(moe::Value(std::string(saslDefaultServiceName)));
+
+ authenticationOptions.addOptionChaining("gssapiHostName", "gssapiHostName", moe::String,
+ "Remote host name to use for purpose of GSSAPI/Kerberos authentication");
+
+ options->addSection(authenticationOptions);
+
options->addOptionChaining("help", "help,h", moe::Switch, "show this usage information");
options->addOptionChaining("version", "version", moe::Switch, "show version information");
@@ -203,6 +216,14 @@ namespace mongo {
params["authenticationMechanism"].as<string>();
}
+ if (params.count("gssapiServiceName")) {
+ shellGlobalParams.gssapiServiceName = params["gssapiServiceName"].as<string>();
+ }
+
+ if (params.count("gssapiHostName")) {
+ shellGlobalParams.gssapiHostName = params["gssapiHostName"].as<string>();
+ }
+
if (params.count("shell")) {
shellGlobalParams.runShell = true;
}