summaryrefslogtreecommitdiff
path: root/src/mongo/client/sasl_client_authenticate_impl.cpp
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2019-12-04 17:12:10 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-12 19:16:45 +0000
commit812c8338f496da3f43174330e37f07f0aad442d3 (patch)
tree80baa88c0eb7aec60fe1d199b27308deae87d49c /src/mongo/client/sasl_client_authenticate_impl.cpp
parent37d1ef0d02582ac95a2adf835a341e0ead12abb3 (diff)
downloadmongo-812c8338f496da3f43174330e37f07f0aad442d3.tar.gz
SERVER-44858 Implement speculative sasl auth
create mode 100644 jstests/auth/speculative-auth-replset.js create mode 100644 jstests/auth/speculative-sasl-start.js create mode 100644 jstests/ssl/speculative-auth-replset.js create mode 100644 jstests/ssl/speculative-authenticate.js create mode 100644 src/mongo/db/auth/sasl_commands.h create mode 100644 src/mongo/db/s/balancer/core_options_stub.cpp
Diffstat (limited to 'src/mongo/client/sasl_client_authenticate_impl.cpp')
-rw-r--r--src/mongo/client/sasl_client_authenticate_impl.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mongo/client/sasl_client_authenticate_impl.cpp b/src/mongo/client/sasl_client_authenticate_impl.cpp
index 61dfbefd446..860f913971b 100644
--- a/src/mongo/client/sasl_client_authenticate_impl.cpp
+++ b/src/mongo/client/sasl_client_authenticate_impl.cpp
@@ -62,18 +62,20 @@ using std::endl;
namespace {
-// Default log level on the client for SASL log messages.
-const int defaultSaslClientLogLevel = 4;
-
-const char* const saslClientLogFieldName = "clientLogLevel";
+constexpr auto saslClientLogFieldName = "clientLogLevel"_sd;
int getSaslClientLogLevel(const BSONObj& saslParameters) {
- int saslLogLevel = defaultSaslClientLogLevel;
+ int saslLogLevel = kSaslClientLogLevelDefault;
BSONElement saslLogElement = saslParameters[saslClientLogFieldName];
- if (saslLogElement.trueValue())
+
+ if (saslLogElement.trueValue()) {
saslLogLevel = 1;
- if (saslLogElement.isNumber())
+ }
+
+ if (saslLogElement.isNumber()) {
saslLogLevel = saslLogElement.numberInt();
+ }
+
return saslLogLevel;
}
@@ -109,19 +111,12 @@ Status extractPassword(const BSONObj& saslParameters,
}
return Status::OK();
}
+} // namespace
-/**
- * Configures "session" to perform the client side of a SASL conversation over connection
- * "client".
- *
- * "saslParameters" is a BSON document providing the necessary configuration information.
- *
- * Returns Status::OK() on success.
- */
-Status configureSession(SaslClientSession* session,
- const HostAndPort& hostname,
- StringData targetDatabase,
- const BSONObj& saslParameters) {
+Status saslConfigureSession(SaslClientSession* session,
+ const HostAndPort& hostname,
+ StringData targetDatabase,
+ const BSONObj& saslParameters) {
std::string mechanism;
Status status =
bsonExtractStringField(saslParameters, saslCommandMechanismFieldName, &mechanism);
@@ -241,6 +236,7 @@ Future<void> asyncSaslConversation(auth::RunCommandHook runCommand,
});
}
+namespace {
/**
* Driver for the client side of a sasl authentication session, conducted synchronously over
* "client".
@@ -270,7 +266,7 @@ Future<void> saslClientAuthenticateImpl(auth::RunCommandHook runCommand,
// Come C++14, we should be able to do this in a nicer way.
std::shared_ptr<SaslClientSession> session(SaslClientSession::create(mechanism));
- status = configureSession(session.get(), hostname, targetDatabase, saslParameters);
+ status = saslConfigureSession(session.get(), hostname, targetDatabase, saslParameters);
if (!status.isOK())
return status;