relief.melone
relief.melone

Reputation: 3322

Mongodb No Access with admin

I'm running into an odd problem. My local database for testing worked just fine but today after starting

mongod --auth

I couldn't run tests anymore as authentication worked but access to the database was denied.

Now my admin user is in the authdb admin. It has the role of userAdminAnyDatabase. I tried to update the user again with

db.updateUser("admin", 
    {pwd: "somePass", roles:[
        {role: "userAdminAnyDatabase", db: "admin"}
    ]}
);

yet I had no luck. This is what my entry in the database looks like.

{
    "role" : "userAdminAnyDatabase",
    "db" : "admin",
    "isBuiltin" : true,
    "roles" : [ ],
    "inheritedRoles" : [ ]
}

I also checked the documentation again and still have no clue how access is denied (especially when everything worked just fine before). The problem is definitely not in my node application as noSQLBooster also gets denied access. Would appreciate it if someone new what I'm currently doing wrong.

Upvotes: 0

Views: 751

Answers (1)

relief.melone
relief.melone

Reputation: 3322

OK. Here is what I did to fix this. (What still remains unsolved is how the access to the database with the old setup did work)

I not only added the role userAdminAnyDatabase to admin but also dbAdminAnyDatabase and readWriteAnyDatabase

To make my testing more secure I also created a unitTestuser and a defaultUser with rights to the appropriate databases so that I don't run into the danger of dropping my productive database accidentally.

Upvotes: 1

Related Questions