summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/list_collections.cpp
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2021-06-17 10:59:33 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-17 16:34:45 +0000
commit870f8af7b3052d0e866f3b24c7220fef1f9d66f5 (patch)
tree081c2bbd48f932f84d07da0adb338759550f361e /src/mongo/db/commands/list_collections.cpp
parentd8484ccdb02cc9c13784385413722b5d00268081 (diff)
downloadmongo-870f8af7b3052d0e866f3b24c7220fef1f9d66f5.tar.gz
SERVER-57558 Include time-series collections in listCollections with authorizedCollections
Diffstat (limited to 'src/mongo/db/commands/list_collections.cpp')
-rw-r--r--src/mongo/db/commands/list_collections.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index e87d2945abb..326a59aebd4 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -395,23 +395,14 @@ public:
}
} else {
auto perCollectionWork = [&](const CollectionPtr& collection) {
- if (authorizedCollections &&
- (!as->isAuthorizedForAnyActionOnResource(
- ResourcePattern::forExactNamespace(collection->ns())))) {
- return true;
- }
-
- BSONObj collBson = buildCollectionBson(
- opCtx, collection, includePendingDrops, nameOnly);
- if (!collBson.isEmpty()) {
- _addWorkingSetMember(
- opCtx, collBson, matcher.get(), ws.get(), root.get());
- }
-
if (collection && collection->getTimeseriesOptions() &&
!collection->ns().isDropPendingNamespace() &&
viewCatalog->lookupWithoutValidatingDurableViews(
- opCtx, collection->ns().getTimeseriesViewNamespace().ns())) {
+ opCtx, collection->ns().getTimeseriesViewNamespace().ns()) &&
+ (!authorizedCollections ||
+ as->isAuthorizedForAnyActionOnResource(
+ ResourcePattern::forExactNamespace(
+ collection->ns().getTimeseriesViewNamespace())))) {
// The time-series view for this buckets namespace exists, so add it
// here while we have the collection options.
_addWorkingSetMember(
@@ -422,6 +413,19 @@ public:
root.get());
}
+ if (authorizedCollections &&
+ (!as->isAuthorizedForAnyActionOnResource(
+ ResourcePattern::forExactNamespace(collection->ns())))) {
+ return true;
+ }
+
+ BSONObj collBson = buildCollectionBson(
+ opCtx, collection, includePendingDrops, nameOnly);
+ if (!collBson.isEmpty()) {
+ _addWorkingSetMember(
+ opCtx, collBson, matcher.get(), ws.get(), root.get());
+ }
+
return true;
};