0
votes

I added an 'admin' user in the admin db, with roles on admin db and another db :

    [admin] user: yves>db.auth("isabelle", "abc123")
    1

    [admin] user: isabelle>db.getUser("isabelle")
    {
        "_id" : "admin.isabelle",
        "user" : "isabelle",
        "db" : "admin",
        "roles" : [
            {
                "role" : "userAdmin",
                "db" : "admin"
            },
            {
                "role" : "dbOwner",
                "db" : "cockpit"
            }
        ]
    }

I am testing that this user cannot admin the 'test' database ( updating a tester user email )

    [admin] user: isabelle>use test
    switched to db test
    [test] user: isabelle>db.updateUser(
    ... "myTester",
    ... {
    ... customData: {email: "[email protected]"}
    ... }
    ... )

As 'isabelle' has no roles on 'test' db , she should not be allowed to update any user on this db ... (?) but it is ...

    [test] user: isabelle>db.getUser("myTester")
    {
        "_id" : "test.myTester",
        "user" : "myTester",
        "db" : "test",
        "roles" : [
            {
                "role" : "readWrite",
                "db" : "test"
            },
            {
                "role" : "read",
                "db" : "reporting"
            }
        ],
        "customData" : {
            "email" : "[email protected]"
        }
    }

what am I missing ? do the isabelle' role 'userAdmin' on 'admin' db allow it ? I tried to remove it, but it deosn(t change anything ...

I also tried to move isabelle in the cockpit database, with dbOwner role, it doesn't change anything... isabelle is still able to update myTester user in the test database...

how can I restrict isabelle to admin only the 'cockpit' db ( managing users and roles for this db ..?

thanks for enlightment ...

1

1 Answers

0
votes

Add to your mongod.conf

security:
   authorization: enabled

Also check this mongodb link.