I tried the following
from pymongo import MongoClient
mongo=MongoClient()
mongo.test.command("createUser", "testing", pwd="testing", roles=["read"])Then I authenticate
mongo.test.authenticate('testing', 'testing')However if I try to insert a document, it actually does insert:
mongo.test.test.insert_one({'name':'vincent'})The command mongo.test.command("usersInfo") returns
{'ok': 1.0,
'users': [{'_id': 'test.testing',
'db': 'test',
'roles': [{'db': 'test', 'role': 'read'}],
'user': 'testing'}]}Which seems to indicate that the user has been created properly. What should I do in order to create and authenticate with a read-only user that would see his insert requests rejected?