Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you secure the client side MongoDB API?

Tags:

meteor

I don't want just all of my users being able to insert/destroy data.

like image 302
TK421 Avatar asked Apr 11 '12 22:04

TK421


People also ask

What is MongoDB client encryption?

New in MongoDB 4.2 client side encryption allows administrators and developers to encrypt specific data fields in addition to other MongoDB encryption features. With field level encryption, developers can encrypt fields client side without any server-side configuration or directives.

Does client side need encryption?

If you're looking for the most secure, private way to send email or transmit data, client-side encryption is your best bet. Using client-side email encryption makes it less likely for your information to be intercepted by hostile third parties on the Internet.


1 Answers

While there is no documented way to do this yet, here's some code that should do what you want:

Foo = new Meteor.Collection("foo"); ... if (Meteor.is_server) {    Meteor.startup(function () {        Meteor.default_server.method_handlers['/foo/insert'] = function () {};        Meteor.default_server.method_handlers['/foo/update'] = function () {};        Meteor.default_server.method_handlers['/foo/remove'] = function () {};    }); } 

This will disable the default insert/update/remove methods. Clients can try to insert into the database, but the server will do nothing, and the client will notice and remove the locally created item when the server responds.

insert/update/remove will still work on the server. You'll need to make methods with Meteor.methods that run on the server to accomplish any database writes.

All of this will change when the authentication branch lands. Once that happens, you'll be able to provide validators to inspect and authorize database writes on the server. Here's a little more detail: http://news.ycombinator.com/item?id=3825063

like image 168
n1mmy Avatar answered Nov 01 '22 14:11

n1mmy