What would the pros / cons be of putting users that should have access to one database in the admin database instead of the database that they should have access to?


I'm a C# developer. This is the first live project using mongodb I'm working on.

I would like to know from people used to managing mongodb instances how they go about setting up users.

In this case I want three users, one for administration, one "webuser" that the intranet web application which I develop will use to read and write documents in one database and a reader user used when read access is enough. Both the readwrite and the reader user just need acces to one database. The admin user should be admin of the mongoserver. The database will be hosted on the server that hosts the web

  • @Akina: Would you be suggesting that putting the users in the admin database might risk a leakage of rights? – mortb Jun 1 '18 at 8:10

in general not just Mongo talking in general given root/sysadmin privileges or adding all users to the admin groups is not recommended due to obvious reasons. And in mongo like advanced databases there are enriched security groups and roles can be created and assign each user as per the requirement. please refer the mongo documentation on creating user roles and assigning privileges. https://docs.mongodb.com/manual/tutorial/manage-users-and-roles/

  • To me this answer translates to read the manual, which of course I already did... – mortb Jun 19 '18 at 13:29

If you want those users to access only the one particular database and no other - then you don't have to.

Have a look here: MongoDB security reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.