Mongodb – restrict user’s access on a certain IP

mongodb

Like in a certain way in MySQL.

CREATE 'dbuser'@'10.1.0.1' identitifed by 'password';

GRANT USAGE on *.* to 'dbuser'@'10.1.0.1';

We are not using any mongodb tools except for Robo

Best Answer

When you create a user then you can specify Authentication Restrictions

Would be like this:

use admin
db.createUser(
   {
     user: "dbuser",
     pwd: "password"
     roles: [ { role: "readWrite", db: "reporting" } ],
     authenticationRestrictions: [ {
        clientSource: ["192.0.2.0"],
        serverAddress: ["198.51.100.0"]
     } ]
   }
)

But for me it is not clear, if you are looking for this.