0

The problem is I have multiple couchdb local clients databases say A_db, B_db, C_db which is replicating to a couchdb server master database says server_db. Now each client is creating a document say A_doc, B_doc, C_doc in their local db which automatically replicating to server_db. So now server_db will have 3 documents, one for each client. Since every client can see all documents of server_db using

server_db/_all_docs?include_docs=true

But I want to restrict clients to read/write other client documents which is on server_db. And only server_db admin to view documents all documents.

atultherajput
  • 175
  • 3
  • 18

1 Answers1

1

Document level read restriction is not supported by CouchDB. I point you to a similar question:

The suggested pattern is to have a db per user or db per role as it seems you are doing.

You should restrict the access to server_db only to authorized users, not to clients.

Some helpful links:

Juanjo Rodriguez
  • 2,103
  • 8
  • 19
  • But if i restrict server_db to authorised users (admin), will clients be able to replicate their dbs to server_db? – atultherajput Feb 17 '18 at 10:48
  • Each client should replicate with its own database in the server, i.e. A_db local db should replicate to A_db server db. Then you can do a server side sync between de server client db and the centralized server database. – Juanjo Rodriguez Feb 18 '18 at 17:13
  • Is there is another way if we don't want to create client db copies at server, I mean directly from client local db to centralized server db? – atultherajput Feb 19 '18 at 04:43
  • And secondly I am not able to create local client db copy on server with non-admin user privilege during replication. – atultherajput Feb 19 '18 at 06:52
  • You will need some server side logic to implement the pattern. I include some links in the answer. – Juanjo Rodriguez Feb 19 '18 at 07:55