CouchDB read/write restrictions on _users database

老子叫甜甜 提交于 2019-12-10 08:48:54

问题


I would like to restrict the user permissions so that a normal user is only able to read/write its own user document.

I managed to set the write permissions such that a user can only edit their own document (via the validate_doc_update function in the design document).

Now I only have to limit a user from viewing the user list or other user documents. If I set the database read permissions to the '_admin' role, then the user will not be able to view their own document, which it's not what I intend.

Can this be done in a more general way? I.e. to set read permissions such that a user is able to read only some specific documents in the database?


回答1:


Unfortunately, per-document read control is not possible.

However, if you use a list function you can perform a "post-query filter" that limits the results of a view query based on the current session user. (via the userCtx parameter)




回答2:


In CouchDB creating a new database is cheap and it was designed to keep the data as close as possible to the user who needs it. So the suggested approach is to have one database for each user.



来源:https://stackoverflow.com/questions/5418700/couchdb-read-write-restrictions-on-users-database

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