Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Atlas: user is not allowed to do action find on system.indexes

I'm using MongoDB Atlas and I've recently started to get this error on my MongoDB replica:

user is not allowed to do action [find] on [mydb.system.indexes]

Nothing really has changed, so I'm wondering what can be an issue. The user has readWrite role on mydb and from the docs it looks like it should have the right to do it. Also, I've tried to change the user to admin user which has any rights, but still got this error. Interesting that system collection doesn't exists in mydb but Spring Data tries to query it and gets this error.

Here is a full log from mongo:

Error: error: {
    "ok" : 0,
    "errmsg" : "user is not allowed to do action [find] on [mydb.system.indexes]",
    "code" : 8000,
    "codeName" : "AtlasError"
}

MongoDB connection URI looks like this:

spring.data.mongodb.uri=mongodb+srv://[USER]:[PASSWORD]@[MONGO_URL].mongodb.net/mydb

I'm using Spring Boot 2.0.1.RELEASE with mongo java driver of version 3.6.3. Version of the Mongo replica is 3.4.14. Any idea what's going on and how this can be fixed? Upgrading user role doesn't help here.

like image 780
Yuriy Yunikov Avatar asked Jan 29 '23 06:01

Yuriy Yunikov


1 Answers

MongoDB Atlas forbids direct calls to some system. collections and they specify that in the doc and db.<COLLECTION>.getIndexes() should be used instead. In my case MongoBee library was making system.indexes call and causing the issue. See my answer here for more details.

like image 68
Yuriy Yunikov Avatar answered Feb 01 '23 17:02

Yuriy Yunikov