-
Edit - added a little clarification to the example below Determine which documents and document fields are returned by a GET request applying a process virtually identical to 'validate_doc_update' functions. SummaryDisclaimer: I have already seen the various opened issues about 'per document access' here, here and here and this isn't the same as those, at least as far as I can tell. What I have in mind is to apply a validate function to not only PUT requests as done currently but also to GET requests to allow individual db users to completely control which documents and which part of those documents they want to share. Desired BehaviourWhen a GET request is made, CouchDB looks for a 'validate_doc_request' (VDR) function (similarly to a 'validate_doc_update' function) and, if it exists, the requested document is passed to it. Whatever the VDR returns due to filtering/restriction code is what is sent to the requesting client. Possible SolutionWhen a PUT request with a document is made, a 'validate_doc_update' (VDU) function is called to apply restrictions, filtering, etc. In the same way, when a GET request for a specific document is made, run a 'validate_doc_request' (VDR) function. CouchDB would grab the requested document and send it to the VDR which would be able to apply filtering, restrictions, conditional statements, security object considerations, etc. and return only a subset (or empty) of that document along with the '_id' and '_rev' fields. All returned fields would contain a path from root to 'position in document' in order to keep track of where data subsets originated in the document. After a user modifies the returned document and sends it back, CouchDB would run a 'merge subset with parent document' function before sending to VDU for validation. For security reasons, if a returned value's 'path' cannot be matched in the original doc then the merging of that value will be ignored. That's all. Here's a quick example to demonstrate.
*note - field_wrong is ignored because there is no matching path in original document
That's it. Please let me know if I need to clarify further. Also, if this is infeasible for "behind the scenes" Erlang restrictions and/or CouchDB architectural reasons let me know and I can remove this proposal. Thanks! Additional contextDespite no longer being recommended from a development perspective, I'm still interested in the two-tier stack idea of CouchDB and what sorts of applications can be created by making the most of the built-in server capabilities. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Heya, thanks for taking the time to think this through and to write it up. The major issue with this approach is that reverse-VDU would be prohibitively slow for general operation. We are already in talks of redesigning the current VDU system to improve validated-write speed, so adding another slow path does not sound like a good idea :) In addition, this approach ignores other features of CouchDB, like If you have any feedback on https://lists.apache.org/thread.html/rf75e0b8266c678bcfdc2e5655317c716f5d317e9cb2f75b326820311%40%3Cdev.couchdb.apache.org%3E that’d be most appreciated, as this is the closest to being shipped. |
Beta Was this translation helpful? Give feedback.
-
I took a look at the RFC and noticed these two lines:
It is the first issue that I'm attempting to solve without a separate application layer and why I made this discussion. I am interested to see how, as you said in the RFC, "the design of this iteration aims to allow turning these non-goals into actual goals later". Without digging deeper into CouchDB's internals I don't feel qualified yet to give further technical feedback/critique. Thanks again for your efforts. |
Beta Was this translation helpful? Give feedback.
-
(1) Question: can a user also be a role? I understand that it would work like this i.e. having a key:value inside each document: But will it also be possible to use a role for the access criteria? (2) Quetion: In terms of speed and performance will it make any difference if one utilizes the partitioned database structure i.e. places all documents of a particular user in a specific partition? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Heya, thanks for taking the time to think this through and to write it up.
The major issue with this approach is that reverse-VDU would be prohibitively slow for general operation. We are already in talks of redesigning the current VDU system to improve validated-write speed, so adding another slow path does not sound like a good idea :)
In addition, this approach ignores other features of CouchDB, like
_all_docs
and_changes
, as well as_revs_diff
, all of which are essential to CouchDB use, so it is not practical for a full solution.If you have any feedback on https://lists.apache.org/thread.html/rf75e0b8266c678bcfdc2e5655317c716f5d317e9cb2f75b326820311%40%3Cdev.couchdb.apache.org%3E th…