简体   繁体   English

保护couchdb和pouchdb复制

[英]Securing couchdb and pouchdb replication

I am trying to get my head around security in couchdb replication. 我试图在couchdb复制中解决安全问题。 I am looking at using pouchdb locally on clients and have the clients sync with a central couchdb. 我正在寻找在客户端上本地使用pouchdb的方法,并让客户端与中央Couchdb同步。 Each client has a doc that only they should be able to sync bidirectionally. 每个客户端都有一个文档,只有它们应该可以双向同步。 How do I ensure users can only sync their own documents, yet have shared documents replicated one-way from couchdb to clients? 如何确保用户只能同步自己的文档,但是将共享文档从couchdb单向复制到客户端?

You can use "pouchdb-authentication" ( https://github.com/nolanlawson/pouchdb-authentication)to secure your connection and PouchDB itself to sync the data with a remote CouchDB server ( https://pouchdb.com/api.html#sync ). 您可以使用“pouchdb-authentication”( https://github.com/nolanlawson/pouchdb-authentication)来保护您的连接,并使用PouchDB本身将数据与远程CouchDB服务器同步( https://pouchdb.com/api。 html #sync )。

Use a "_design" document in each database to restrict access in a users database. 在每个数据库中使用“ _design”文档来限制对用户数据库的访问。

One database per user is quite common for CouchDB. 每个用户一个数据库对于CouchDB来说非常普遍。 In that case, you can allow each user to only access his own database: 在这种情况下,您可以允许每个用户只访问自己的数据库:

https://stackoverflow.com/a/11686674 https://stackoverflow.com/a/11686674

If each user needs just one document, then each database contains just one doc! 如果每个用户只需要一个文档,那么每个数据库只包含一个文档!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM