diff options
author | Spencer T Brody <spencer@10gen.com> | 2013-10-18 18:34:31 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2013-10-23 18:38:18 -0400 |
commit | a9eb91679a5df939c8fbe0fb5737588ee0f758a1 (patch) | |
tree | 8a90c3220ea8e0a3fac9e53107c45f1170573be3 /src/mongo/db/auth/user_management_commands_parser.cpp | |
parent | 2bc327964e59cfc7d2a0a5241df04d56b5a039a3 (diff) | |
download | mongo-a9eb91679a5df939c8fbe0fb5737588ee0f758a1.tar.gz |
SERVER-10855 Add option to let client hash user's password.
Diffstat (limited to 'src/mongo/db/auth/user_management_commands_parser.cpp')
-rw-r--r-- | src/mongo/db/auth/user_management_commands_parser.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mongo/db/auth/user_management_commands_parser.cpp b/src/mongo/db/auth/user_management_commands_parser.cpp index e03ff1c4478..cc2615ad13b 100644 --- a/src/mongo/db/auth/user_management_commands_parser.cpp +++ b/src/mongo/db/auth/user_management_commands_parser.cpp @@ -212,6 +212,7 @@ namespace auth { unordered_set<std::string> validFieldNames; validFieldNames.insert(cmdName.toString()); validFieldNames.insert("customData"); + validFieldNames.insert("digestPassword"); validFieldNames.insert("pwd"); validFieldNames.insert("roles"); validFieldNames.insert("writeConcern"); @@ -239,16 +240,29 @@ namespace auth { // Parse password if (cmdObj.hasField("pwd")) { - std::string clearTextPassword; - status = bsonExtractStringField(cmdObj, "pwd", &clearTextPassword); + std::string password; + status = bsonExtractStringField(cmdObj, "pwd", &password); if (!status.isOK()) { return status; } - if (clearTextPassword.empty()) { + if (password.empty()) { return Status(ErrorCodes::BadValue, "User passwords must not be empty"); } - parsedArgs->hashedPassword = auth::createPasswordDigest(userName, clearTextPassword); + bool digestPassword; // True if the server should digest the password + status = bsonExtractBooleanFieldWithDefault(cmdObj, + "digestPassword", + true, + &digestPassword); + if (!status.isOK()) { + return status; + } + + if (digestPassword) { + parsedArgs->hashedPassword = auth::createPasswordDigest(userName, password); + } else { + parsedArgs->hashedPassword = password; + } parsedArgs->hasHashedPassword = true; } |