Search code examples
mongodbmongodb-querymongodb-shell

MongoDb shell simple find(): Why not authorized?


How is this even possible? What am I missing?...

Non-sense query denial

Edit 1: Ignore the db.posts.find vs. db.post.find typo above. I re-auth'd and tried the latter and get exact same denial.

Am I dumb or do MongoDb permissions make no sense at all? Ok don't answer that first part ;-)

Thanks a lot for any advice, I'm stuck on this one.


Solution

  • You grant only roles to the db admin. Not on d6games-site.

    Try using:

    db.grantRolesToUser(
      "webuser",
      [
        { role: "readWrite", db: "d6games-site" } ,
      ]
    )
    

    and very probably:

    db.revokeRolesFromUser(
        "webuser",
        [
          { role: "readWrite", db: "admin" }
        ]
    )