From 0a801f1e152136be8cd0d7c57fda71555042cca1 Mon Sep 17 00:00:00 2001 From: Spencer Jackson Date: Mon, 31 Jul 2017 11:21:40 -0400 Subject: SERVER-29182: Add restriction support to the usersInfo command --- src/mongo/db/auth/user_management_commands_parser.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/mongo/db/auth/user_management_commands_parser.cpp') diff --git a/src/mongo/db/auth/user_management_commands_parser.cpp b/src/mongo/db/auth/user_management_commands_parser.cpp index f1ab1f40735..ec10ce928f7 100644 --- a/src/mongo/db/auth/user_management_commands_parser.cpp +++ b/src/mongo/db/auth/user_management_commands_parser.cpp @@ -323,6 +323,7 @@ Status parseAndValidateDropAllUsersFromDatabaseCommand(const BSONObj& cmdObj, Status parseUsersInfoCommand(const BSONObj& cmdObj, StringData dbname, UsersInfoArgs* parsedArgs) { unordered_set validFieldNames; validFieldNames.insert("usersInfo"); + validFieldNames.insert("showAuthenticationRestrictions"); validFieldNames.insert("showPrivileges"); validFieldNames.insert("showCredentials"); @@ -364,6 +365,20 @@ Status parseUsersInfoCommand(const BSONObj& cmdObj, StringData dbname, UsersInfo return status; } + const auto showAuthenticationRestrictions = cmdObj["showAuthenticationRestrictions"]; + if (showAuthenticationRestrictions.eoo()) { + parsedArgs->authenticationRestrictionsFormat = AuthenticationRestrictionsFormat::kOmit; + } else { + bool show; + status = bsonExtractBooleanField(cmdObj, "showAuthenticationRestrictions", &show); + if (!status.isOK()) { + return status; + } + parsedArgs->authenticationRestrictionsFormat = show + ? AuthenticationRestrictionsFormat::kShow + : AuthenticationRestrictionsFormat::kOmit; + } + return Status::OK(); } -- cgit v1.2.1