db["system.views"].countDocuments() - unauthorised access

Running some js, I see
MongoServerError[Unauthorized]: not authorized on mydb to execute command { find: “system.views”, filter: { _id: ObjectId(‘xxxxxxxxxxxxx’) }, limit: 1, lsid: { id: UUID(“xxxxxxxxxxxxxxxx”) }, $db: “mydb” }authenticationDatabase admin

mongo 6*

admin> db.getUser(‘me’)
{
_id: 'admin.me,
userId: UUID(‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’),
user: 'me,
db: ‘admin’,
roles: [
{ role: ‘root’, db: ‘admin’ },
{ role: ‘readAnyDatabase’, db: ‘admin’ },
{ role: ‘dbAdminAnyDatabase’, db: ‘admin’ }
]
}

What’s going on here, do I need additional roles ? Feel I’m missing something … !
Thanks

You can ignore this guys. Found a bug in the code which meant it was trying to do a findOne directly against system.views, (in a “for all collections” loop) which it shouldn’t have been trying to do.

1 Like