I have a database in mongoDB 2.6.4 in which I want to restrict the users as per their level. I want to give read privileges to some users and insert/update privileges to some other users on a particular database. Please let me know how I can create user defined roles and assign them to the users. I tried the below but it is not working; the users still have full privileges:
db.runCommand({createRole: "read",
privileges: [
{ resource: { db: "sample", collection: "" },
actions: [ "find" ]
}],
roles: [],
writeConcern: { w: "majority" , wtimeout: 5000 }
})
==================================================================================
db.addUser( { user : "read",
pwd : "read",
roles:["read"]
} )
Aucun commentaire:
Enregistrer un commentaire