MongoDB setting permission for functions

mongodb-3.2permissions

I want to create execute permission on some MongoDB functions
like permissions in Sql Server.

I want users access data that function provides for them. This is, because of security of application
that don't other team staf change collections.

Is there any solution for doing this?

Best Answer

Finally I got the answer. For executing user defined javascript functions in MongoDB first of all need to call db.loadServerScripts().

Every database in Mongo has a collection named system.js, which is in systems collections group.We can define our roles and permissions for collections and define privilage for system.js collection too.

If any function uses collections that we don't have permission to use, function will not execute and return authorization error, if collection have those privilages, funcion execute successfully