summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/dbcommands.cpp
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2022-09-26 12:16:57 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-04 16:51:46 +0000
commit5ff2f41b0dbad9ef4d96b1407b06a044c0b41c48 (patch)
tree707d5150c1616ab7c41412697c4b19b950731c44 /src/mongo/db/commands/dbcommands.cpp
parent810d5c1f2b0f8d3767df55812c3324d6171aa107 (diff)
downloadmongo-5ff2f41b0dbad9ef4d96b1407b06a044c0b41c48.tar.gz
SERVER-70146 Migrate checkAuthForCommand to checkAuthForOperation
Diffstat (limited to 'src/mongo/db/commands/dbcommands.cpp')
-rw-r--r--src/mongo/db/commands/dbcommands.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index c6f8a329fd1..19fd21c513e 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -432,9 +432,9 @@ public:
using Request = CollStatsCommand;
Status checkAuthForOperation(OperationContext* opCtx,
- const DatabaseName& dbname,
+ const DatabaseName& dbName,
const BSONObj& cmdObj) const final {
- const auto nss = CommandHelpers::parseNsCollectionRequired(dbname, cmdObj);
+ const auto nss = CommandHelpers::parseNsCollectionRequired(dbName, cmdObj);
auto as = AuthorizationSession::get(opCtx->getClient());
if (!as->isAuthorizedForActionsOnResource(ResourcePattern::forExactNamespace(nss),
ActionType::collStats)) {
@@ -513,10 +513,11 @@ public:
"Example: { collMod: 'foo', index: {name: 'bar', expireAfterSeconds: 600} }\n";
}
- virtual Status checkAuthForCommand(Client* client,
- const std::string& dbname,
- const BSONObj& cmdObj) const {
- const NamespaceString nss(parseNs({boost::none, dbname}, cmdObj));
+ Status checkAuthForOperation(OperationContext* opCtx,
+ const DatabaseName& dbName,
+ const BSONObj& cmdObj) const override {
+ auto client = opCtx->getClient();
+ auto nss = parseNs(dbName, cmdObj);
return auth::checkAuthForCollMod(
client->getOperationContext(), AuthorizationSession::get(client), nss, cmdObj, false);
}