CouchDB Read and Write Restrictions for _users Database

I would like to restrict user rights so that a regular user can read / write their own user document.

I was able to set write permissions so that the user can edit his own document (via the validate_doc_update function in the project document).

Now I only need to restrict the user to viewing the list of users or other user documents. If I set the database permissions for the "_admin" role, the user will not be able to view his own document, which I do not intend to.

Can this be done in a more general way? That is, set read permissions so that the user can read only certain documents in the database?

+4
source share
2 answers

Unfortunately, managing the reading of each document is not possible.

However, if you use the list function , you can run a "filter after the query", which limits the results of the query to the view based on the current session user. (via the userCtx parameter)

+1
source

At 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. Therefore, the proposed approach is to have one database for each user.

0
source

Source: https://habr.com/ru/post/1345070/


All Articles