Reputation: 23737
I am thinking in using MongoDB as my main database. However, my app is fully in JavaScript and I wanted to use the REST API, client side.
I still can't understand what security mechanisms can I use in order to make a JS call to the database without revealing all the data to all the users.
Please advice on this matter.
Regards, Donald
Upvotes: 8
Views: 4969
Reputation: 1253
RESTHeart is a Web API for MongoDB.
It provides application level authorization and authentication.
Check the security documentation section.
Also some example applications are available on github:
Upvotes: 0
Reputation: 393
MongoLab has MongoDB database hosting with a REST API that can be accessed client side, they even through in some jQuery based examples in their support documentation. That said, Remon is right that you sacrifice any security by doing so because you're making your API key public.
Upvotes: 1
Reputation: 41882
Check out Sleepy.Mongoose, it's a REST API interface for MongoDB. I haven't tried it, but it appears to support standard MongoDB authentication.
Upvotes: 2
Reputation: 18595
First of all, you can enable database auth which will make the REST interface require authentication if connected to from a remote machine.
That said, it's a very bad idea to expose your database like you suggest. Build a persistence abstraction layer in a server technology you're comfortable with (node.js for example) and put all security constraints and authentication there. The advantages are numerous :
Upvotes: 5