MongoDB super-admin authenticates fine but still gets unauthorized query errors?

10,133

The userAdminAnyDatabase role (and the userAdmin role that it is an extension of) simply gives your user the permission to read and write to the system.users collection to administer the users of a database. It doesn't allow the user to read or write to the actual collections of the database. For that, you need to grant the read or readWrite roles.

See User Privilege Roles in MongoDB and Add a User to a Database.

Share:
10,133

Related videos on Youtube

Robert Oschler
Author by

Robert Oschler

Updated on September 18, 2022

Comments

  • Robert Oschler
    Robert Oschler almost 2 years

    I have started using MongoDB with authentication. As per the documentation I used the localhost exception to create an admin user with the single role of userAdminAnyDatabase. That all went fine. When I run the "mongo" client and authorize against the admin database after using that database I get the number 1 indicating that authorization succeeded. However, any command I try to execute results in an "unauthorized" error, even trying to show the collections in the admin database I just authorized against.

    Can anyone tell me why this is and how I can fix it? Currently I am running without authentication until I can get this fixed.