Example of 'AuthAppRole' user role
use admin
db.createRole({
role: "AuthAppRole",
privileges: [
{
resource: { db: "fail2ban", collection: "ban" },
actions: [ "insert" ]
}
],
roles: [
{ role: "readWrite", db: "Auth" },
{ role: "dbAdmin", db: "Auth" }
]
})
role stored in admin database
user stored in Auth database
use Auth
db.updateUser("ans1",{
roles:[{role:'AuthAppRole',db:'admin'}]
})