[SERVER-57558] listCollections with {nameOnly: true, authorizedCollections: true} does not return timeseries collections Created: 09/Jun/21  Updated: 29/Oct/23  Resolved: 17/Jun/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.0-rc0
Fix Version/s: 5.0.0-rc3, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Steps To Reproduce:

1. Start mongod with --auth
2. There are two scripts a setup.js that needs to be run only once. And a repro.js script that can be run many times.
//////////////
Setup.js
////////////////////
function createTestRoleAndUser(db, roleName, privs) {
const admin = db.getSiblingDB("admin");
assert.commandWorked(admin.runCommand(

{createRole: roleName, roles: [], privileges: privs}

));

const userName = "user|" + roleName;
assert.commandWorked(
db.runCommand({createUser: userName, pwd: "pwd", roles: [

{role: roleName, db: "admin"}

]}));
}

const dbName = "list_collections_own_collections";

const admin = db.getSiblingDB("admin");
assert.commandWorked(admin.runCommand(

{createUser: "root", pwd: "root", roles: ["root"]}

));
assert(admin.auth("root", "root"));

const db2 = db.getSiblingDB(dbName);

createTestRoleAndUser(db2, "roleWithExactNamespacePrivilegesBuckets", [
{resource:

{db: dbName, collection: "foo"}

, actions: ["find"]},
]);

// Create the collection and view used by the tests.
assert.commandWorked(db2.dropDatabase());
assert.commandWorked(db2.createCollection("foo", {timeseries: {timeField: "date"}}));
///////////////////
Repro.js
//////////////

const userName = "user|roleWithExactNamespacePrivilegesBuckets";
const dbName = "list_collections_own_collections";

const db2 = db.getSiblingDB(dbName);

const admin = db.getSiblingDB("admin");

assert(db2.auth(userName, "pwd"));

let res = db2.runCommand(

{listCollections: 1, nameOnly: true, authorizedCollections: true}

);
assert.commandWorked(res);
print(tojson(res));
// Bug is that res is empty, it should have the foo collection.

Sprint: Execution Team 2021-06-28
Participants:

 Description   

As a result of SERVER-56933, when a user has privileges on timeseries example_db.example_coll, and the user runs listCollections: 1, nameOnly: true, authorizedCollections: true, the listCollections command does not return the time series collection in the results.

This is the result of an early exit in a lambda function here.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 17/Jun/21 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-57558 Include time-series collections in listCollections with authorizedCollections

(cherry picked from commit 870f8af7b3052d0e866f3b24c7220fef1f9d66f5)
Branch: v5.0
https://github.com/mongodb/mongo/commit/79815286e32e2fa88d0e08759cc9bfded8cad8fc

Comment by Githook User [ 17/Jun/21 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-57558 Include time-series collections in listCollections with authorizedCollections
Branch: master
https://github.com/mongodb/mongo/commit/870f8af7b3052d0e866f3b24c7220fef1f9d66f5

Generated at Thu Feb 08 05:42:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.