diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/auth/internal_user_auth.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/auth/internal_user_auth.cpp')
-rw-r--r-- | src/mongo/db/auth/internal_user_auth.cpp | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src/mongo/db/auth/internal_user_auth.cpp b/src/mongo/db/auth/internal_user_auth.cpp index 6c8190845ea..5cc90c29ea9 100644 --- a/src/mongo/db/auth/internal_user_auth.cpp +++ b/src/mongo/db/auth/internal_user_auth.cpp @@ -39,78 +39,78 @@ #include "mongo/util/log.h" namespace mongo { - namespace mmb = mongo::mutablebson; +namespace mmb = mongo::mutablebson; - // not guarded by the authParams mutex never changed in - // multi-threaded operation - static bool authParamsSet = false; +// not guarded by the authParams mutex never changed in +// multi-threaded operation +static bool authParamsSet = false; - // Store default authentication parameters for internal authentication to cluster members, - // guarded by the authParams mutex - static BSONObj authParams; +// Store default authentication parameters for internal authentication to cluster members, +// guarded by the authParams mutex +static BSONObj authParams; - static stdx::mutex authParamMutex; +static stdx::mutex authParamMutex; - bool isInternalAuthSet() { - return authParamsSet; - } - - void setInternalUserAuthParams(const BSONObj& authParamsIn) { - if (!isInternalAuthSet()) { - authParamsSet = true; - } - stdx::lock_guard<stdx::mutex> lk(authParamMutex); +bool isInternalAuthSet() { + return authParamsSet; +} - if (authParamsIn["mechanism"].String() != "SCRAM-SHA-1") { - authParams = authParamsIn.copy(); - return; - } +void setInternalUserAuthParams(const BSONObj& authParamsIn) { + if (!isInternalAuthSet()) { + authParamsSet = true; + } + stdx::lock_guard<stdx::mutex> lk(authParamMutex); - // Create authParams for legacy MONGODB-CR authentication for 2.6/3.0 mixed - // mode if applicable. - mmb::Document fallback(authParamsIn); - fallback.root().findFirstChildNamed("mechanism").setValueString("MONGODB-CR"); + if (authParamsIn["mechanism"].String() != "SCRAM-SHA-1") { + authParams = authParamsIn.copy(); + return; + } - mmb::Document doc(authParamsIn); - mmb::Element fallbackEl = doc.makeElementObject("fallbackParams"); - fallbackEl.setValueObject(fallback.getObject()); - doc.root().pushBack(fallbackEl); - authParams = doc.getObject().copy(); + // Create authParams for legacy MONGODB-CR authentication for 2.6/3.0 mixed + // mode if applicable. + mmb::Document fallback(authParamsIn); + fallback.root().findFirstChildNamed("mechanism").setValueString("MONGODB-CR"); + + mmb::Document doc(authParamsIn); + mmb::Element fallbackEl = doc.makeElementObject("fallbackParams"); + fallbackEl.setValueObject(fallback.getObject()); + doc.root().pushBack(fallbackEl); + authParams = doc.getObject().copy(); +} + +BSONObj getInternalUserAuthParamsWithFallback() { + if (!authParamsSet) { + return BSONObj(); } - BSONObj getInternalUserAuthParamsWithFallback() { - if (!authParamsSet) { - return BSONObj(); - } + stdx::lock_guard<stdx::mutex> lk(authParamMutex); + return authParams.copy(); +} - stdx::lock_guard<stdx::mutex> lk(authParamMutex); - return authParams.copy(); +BSONObj getFallbackAuthParams(BSONObj params) { + if (params["fallbackParams"].type() != Object) { + return BSONObj(); } + return params["fallbackParams"].Obj(); +} - BSONObj getFallbackAuthParams(BSONObj params) { - if (params["fallbackParams"].type() != Object) { - return BSONObj(); +bool authenticateInternalUser(DBClientWithCommands* conn) { + if (!isInternalAuthSet()) { + if (!serverGlobalParams.quiet) { + log() << "ERROR: No authentication parameters set for internal user"; } - return params["fallbackParams"].Obj(); + return false; } - bool authenticateInternalUser(DBClientWithCommands* conn) { - if (!isInternalAuthSet()) { - if (!serverGlobalParams.quiet) { - log() << "ERROR: No authentication parameters set for internal user"; - } - return false; - } - - try { - conn->auth(getInternalUserAuthParamsWithFallback()); - return true; - } catch(const UserException& ex) { - if (!serverGlobalParams.quiet) { - log() << "can't authenticate to " << conn->toString() - << " as internal user, error: "<< ex.what(); - } - return false; + try { + conn->auth(getInternalUserAuthParamsWithFallback()); + return true; + } catch (const UserException& ex) { + if (!serverGlobalParams.quiet) { + log() << "can't authenticate to " << conn->toString() + << " as internal user, error: " << ex.what(); } + return false; } -} // namespace mongo +} +} // namespace mongo |