PouchDB replication of design documents

随声附和 提交于 2019-12-07 18:03:00

问题


I have a Cordova app running PouchDB inside the in-app browser. Each user belongs to a 'team'. For each team, there is a couch database in the cloud that they're all syncing their local pouch with.

I'd like to create a design document that provides some simple filtering functionality, but I'm concerned that any user belonging to that team would be able to create a new revision of the design document and thus affect every other user's view of the documents.

Is it a common practice to lock down updates of design documents? Are these design documents typically replicated between users, or are they created in local pouches only and somehow prevented from replicating to a shared cloud couch?


回答1:


My standard advice to folks is to never replicate design documents. It's just too confusing and security-risky.

Therefore when you replicate, you can just do a filter to exclude any documents whose IDs start with _design/. On the client side, you just create whatever ddocs you need, and ditto with the server.

On the other hand, this doesn't prevent a malicious user from attempting to overwrite design documents on the server-side. (In case you are also using server-side ddocs.) The only way to prevent that is with a validate_doc_update function, which you can use to prevent non-admins from overwriting design docs.

Hope that helps!



来源:https://stackoverflow.com/questions/39256692/pouchdb-replication-of-design-documents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!