You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "Mclean, Adam" <ad...@rbc.com> on 2014/05/15 22:15:48 UTC

Deleting a document that has been 'copied'.

When using my application user which has 'member' permissions in my database, and an entry in the validate_doc_update design document to permit newDoc._deleted:

When I create a document (using POST - document contains inline attachment stubs), I am able to delete that created document without any problems.

If I 'copy' that created document (using http://wiki.apache.org/couchdb/HTTP_Document_API#COPY) to a new document within the same database, I am not able to delete the copied document.  When I attempt to delete the copied document I get response:
{"error":"forbidden","reason":"Only admins may delete documents"}

This 'throw' does not exist anywhere in my validate_doc_update.  Nor can I find it in google (numerous 'Only admins may' matches, but none with that exact phrase).

I'm using Couch 1.3.1.  Have I stumbled on a bug, or is this expected behaviour for copied documents?

Thanks!

_______________________________________________________________________

This email may be privileged and/or confidential, and the
sender does not waive any related rights and obligations.
Any distribution, use or copying of this email or the
information it contains by other than an intended recipient
is unauthorized. If you received this email in error,
please advise the sender (by return email or otherwise)
immediately. You have consented to receive the attached
electronically at the above-noted email address; please retain a
copy of this confirmation for future reference.

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce
pas aux droits et obligations qui s'y rapportent. Toute diffusion,
utilisation ou copie de ce courriel ou des renseignements qu'il
contient par une personne autre que le (les) destinataire(s)
désigné(s) est interdite. Si vous recevez ce courriel par erreur,
veuillez en aviser l'expéditeur immédiatement, par retour de courriel
ou par un autre moyen. Vous avez accepté de recevoir le(s) document(s)
ci-joint(s) par voie électronique à l'adresse courriel indiquée ci-dessus;
veuillez conserver une copie de cette confirmation pour les fins de reference future.

Re: Deleting a document that has been 'copied'.

Posted by Robert Samuel Newson <rn...@apache.org>.
Hm, the phrase "Only admins may delete documents" does not appear in CouchDB itself, are you quoting that exactly? We *do* have phrases like "Only admins may delete other user docs.", so please confirm.

and, while we’re at it, lets absolutely confirm that there are no other validation functions;

curl -s 'localhost:15984/DBNAME/_all_docs?startkey="_design/"&endkey="_design0"&include_docs=true' | jq '.rows[].doc.validate_doc_update'

You’ll need https://stedolan.github.io/jq/ if you don’t already have it.

B.

On 16 May 2014, at 17:14, Mclean, Adam <ad...@rbc.com> wrote:

>> Have you other validate_doc_update functions in other design documents in that database? They all have to pass for an update to succeed.
>> 
>> CouchDB does not apply any additional restrictions to "copied documents", it's just a document like any other. (CouchDB won't even know, afterwards, that you copied it from somewhere else at all).
>> 
>> B.
> 
> Just the one validate_doc_update.  The unusual thing is with the exact same user a document that hasn't been copied can be deleted.  Only after the copy does it become locked down to only 'admins' being able to delete it.  Could it be related to in-line attachments with the copied documents? (I'm creating inline attachments, then copying the document).  Let me put a few test cases together and try it against 1.5.1, and if it still occurs I'll open a bug.
> _______________________________________________________________________
> 
> This email may be privileged and/or confidential, and the
> sender does not waive any related rights and obligations.
> Any distribution, use or copying of this email or the
> information it contains by other than an intended recipient
> is unauthorized. If you received this email in error,
> please advise the sender (by return email or otherwise)
> immediately. You have consented to receive the attached
> electronically at the above-noted email address; please retain a
> copy of this confirmation for future reference.
> 
> Ce courriel est confidentiel et protégé. L'expéditeur ne renonce
> pas aux droits et obligations qui s'y rapportent. Toute diffusion,
> utilisation ou copie de ce courriel ou des renseignements qu'il
> contient par une personne autre que le (les) destinataire(s)
> désigné(s) est interdite. Si vous recevez ce courriel par erreur,
> veuillez en aviser l'expéditeur immédiatement, par retour de courriel
> ou par un autre moyen. Vous avez accepté de recevoir le(s) document(s)
> ci-joint(s) par voie électronique à l'adresse courriel indiquée ci-dessus;
> veuillez conserver une copie de cette confirmation pour les fins de reference future.


RE: Deleting a document that has been 'copied'.

Posted by "Mclean, Adam" <ad...@rbc.com>.
> Have you other validate_doc_update functions in other design documents in that database? They all have to pass for an update to succeed.
> 
> CouchDB does not apply any additional restrictions to "copied documents", it's just a document like any other. (CouchDB won't even know, afterwards, that you copied it from somewhere else at all).
> 
> B.

Just the one validate_doc_update.  The unusual thing is with the exact same user a document that hasn't been copied can be deleted.  Only after the copy does it become locked down to only 'admins' being able to delete it.  Could it be related to in-line attachments with the copied documents? (I'm creating inline attachments, then copying the document).  Let me put a few test cases together and try it against 1.5.1, and if it still occurs I'll open a bug.
_______________________________________________________________________

This email may be privileged and/or confidential, and the
sender does not waive any related rights and obligations.
Any distribution, use or copying of this email or the
information it contains by other than an intended recipient
is unauthorized. If you received this email in error,
please advise the sender (by return email or otherwise)
immediately. You have consented to receive the attached
electronically at the above-noted email address; please retain a
copy of this confirmation for future reference.

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce
pas aux droits et obligations qui s'y rapportent. Toute diffusion,
utilisation ou copie de ce courriel ou des renseignements qu'il
contient par une personne autre que le (les) destinataire(s)
désigné(s) est interdite. Si vous recevez ce courriel par erreur,
veuillez en aviser l'expéditeur immédiatement, par retour de courriel
ou par un autre moyen. Vous avez accepté de recevoir le(s) document(s)
ci-joint(s) par voie électronique à l'adresse courriel indiquée ci-dessus;
veuillez conserver une copie de cette confirmation pour les fins de reference future.

Re: Deleting a document that has been 'copied'.

Posted by Robert Samuel Newson <rn...@apache.org>.
Have you other validate_doc_update functions in other design documents in that database? They all have to pass for an update to succeed.

CouchDB does not apply any additional restrictions to "copied documents", it’s just a document like any other. (CouchDB won’t even know, afterwards, that you copied it from somewhere else at all).

B.

On 15 May 2014, at 21:15, Mclean, Adam <ad...@rbc.com> wrote:

> When using my application user which has 'member' permissions in my database, and an entry in the validate_doc_update design document to permit newDoc._deleted:
> 
> When I create a document (using POST - document contains inline attachment stubs), I am able to delete that created document without any problems.
> 
> If I 'copy' that created document (using http://wiki.apache.org/couchdb/HTTP_Document_API#COPY) to a new document within the same database, I am not able to delete the copied document.  When I attempt to delete the copied document I get response:
> {"error":"forbidden","reason":"Only admins may delete documents"}
> 
> This 'throw' does not exist anywhere in my validate_doc_update.  Nor can I find it in google (numerous 'Only admins may' matches, but none with that exact phrase).
> 
> I'm using Couch 1.3.1.  Have I stumbled on a bug, or is this expected behaviour for copied documents?
> 
> Thanks!
> 
> _______________________________________________________________________
> 
> This email may be privileged and/or confidential, and the
> sender does not waive any related rights and obligations.
> Any distribution, use or copying of this email or the
> information it contains by other than an intended recipient
> is unauthorized. If you received this email in error,
> please advise the sender (by return email or otherwise)
> immediately. You have consented to receive the attached
> electronically at the above-noted email address; please retain a
> copy of this confirmation for future reference.
> 
> Ce courriel est confidentiel et protégé. L'expéditeur ne renonce
> pas aux droits et obligations qui s'y rapportent. Toute diffusion,
> utilisation ou copie de ce courriel ou des renseignements qu'il
> contient par une personne autre que le (les) destinataire(s)
> désigné(s) est interdite. Si vous recevez ce courriel par erreur,
> veuillez en aviser l'expéditeur immédiatement, par retour de courriel
> ou par un autre moyen. Vous avez accepté de recevoir le(s) document(s)
> ci-joint(s) par voie électronique à l'adresse courriel indiquée ci-dessus;
> veuillez conserver une copie de cette confirmation pour les fins de reference future.