MongoDB clusterMonitor role without giving permissions to see all the databases

Viewed 25

I use recently mongodb and I am experimenting with the management of users and roles. I was trying to create a role that could only read a specific database but also see the cluster performance with MongoDB compass, but to do that I have to create it in the admin database, and by doing so the user gets permission to see all the databases

How I create the user:

> use admin

> db.createUser(
  {
    user: 'username',
    pwd: '***',
    roles: [
        { role: "clusterMonitor", db: "admin" },
        { role: "read", db: "MyDatabase"}
      ]
  }
)
1 Answers
Related