开发者

Restricting resource access in CouchDB to exactly 2 users

开发者 https://www.devze.com 2023-01-23 08:39 出处:网络
Currently I\'m in the process of evaluating CouchDB for a new project. Key constraint for this project is strong privacy. There need to be resources that are rea开发者_Python百科dable by exactly two

Currently I'm in the process of evaluating CouchDB for a new project.

Key constraint for this project is strong privacy. There need to be resources that are rea开发者_Python百科dable by exactly two users.

One usecase may be something similar to Direct Messages (DMs) on Twitter. Another usecase would be User / SuperUser access level.

I currently don't have any ideas about how to solve these kind of problems with CouchDB other than creating one Database that is accessable only by these 2 users. I wonder how I would then build views aggregating data from several databases?

Do you have any hints / suggestions for me?


I've asked this question several times on couchdb mailing lists, and never got an answer.

There are a number of things that couchdb is missing.

One of them is the document level security which would :

  • allow only certain users to view a doc
  • filter the documents indexed in a view on a user level permission base

I don't think that there is a solution to the permission considerations with the current couchdb implementation.

One solution would be to use an external indexing tool like lucene, and tag your documents with user rights, then issue a lucene query with user right definition in order to get the docs. It also implies extra load on your server(s) (lucene requires a JVM) and an extra delay for the data to be available (lucene indexing time ... )

As for the several databases solution, there are language framework implementations that simply don't allow to use more then one databases ( for instance couch_potato for Ruby ).

Having several databases also means that you'll have several replication processes if your databases are replicated.

Also, this means that the views will be updated for each of the database. In some cases this is better then have huge views indexed in a single database, but it also means that distinct users might not be up to date for a single source of information ( i.e some will have their views updated, other won't). So you cannot guarantee that the data is consistent for all users.

So unless something is implemented in the couch core in order to manage document level authorizations, CouchDB does not seem appropriate for managing data with privacy constraints.


There are a bunch of details missing about what you are trying to accomplish, what the data looks like, so it's hard to make a specific recommendation. You may be able to create a database per user and copy items into each users database (for the DM use case you described). Each user would only be able to access their own database, and then you could have an admin user that could access all databases. If you need to later update those records copying them to multiple databases might not be a good idea, and then you might consider whether you want to control permissions at a different level from storage.

For views that aggregate data from several databases, I recommend looking at lounge and bigcouch, which take different approaches.

http://tilgovi.github.com/couchdb-lounge/ http://support.cloudant.com/faqs/views/chained-mapreduce-views

0

精彩评论

暂无评论...
验证码 换一张
取 消