开发者

CouchDB read/write restrictions on _users database

开发者 https://www.devze.com 2023-02-19 16:38 出处:网络
I would like to restrict the user permissions so that a normal user is only able to read/write its own user document.

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开发者_如何学Python 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?


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)


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.

0

精彩评论

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