You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by jumbo jim <ju...@gmail.com> on 2014/12/30 04:38:30 UTC

Disable purge? Also, hide all docs?

Hi,

I don't want a particular user to be able to delete any documents - only
create/update. I have a design doc to prevent normal deletion -

function(newDoc, oldDoc, userCtx, secObj) {
    if ( (newDoc._deleted === true) && (userCtx.roles.indexOf('_admin') ===
-1) ) {
throw({forbidden: 'no way!'});
    }
    else{
return;
    }
}

However, the user can still purge! Is there a way to stop this?

Also, is there a way to hide all docs? ie, block this -
http://localhost:5984/DB/_all_docs

I know I could put a proxy in between and block/rewrite _purge or
_all_docs, but is there an easier way?

Thanks

Re: Disable purge? Also, hide all docs?

Posted by Jan Lehnardt <ja...@apache.org>.
> On 30 Dec 2014, at 09:01 , Alexander Shorin <kx...@gmail.com> wrote:
> 
> The easiest way is indeed to put CouchDB behind a proxy, but for
> _all_docs you can just remove this http endpoint from config by adding
> the following in your local.ini
> 
> [httpd_db_handlers]
> _all_docs =
> 
> Suddenly, for _purge you cannot do the same trick. However, you might
> want to open issue on JIRA about since this looks like is an unwelcome
> behaviour.

+1 to file an issue for this.


> --
> ,,,^..^,,,
> 
> 
> On Tue, Dec 30, 2014 at 6:38 AM, jumbo jim <ju...@gmail.com> wrote:
>> Hi,
>> 
>> I don't want a particular user to be able to delete any documents - only
>> create/update. I have a design doc to prevent normal deletion -
>> 
>> function(newDoc, oldDoc, userCtx, secObj) {
>>    if ( (newDoc._deleted === true) && (userCtx.roles.indexOf('_admin') ===
>> -1) ) {
>> throw({forbidden: 'no way!'});
>>    }
>>    else{
>> return;
>>    }
>> }
>> 
>> However, the user can still purge! Is there a way to stop this?
>> 
>> Also, is there a way to hide all docs? ie, block this -
>> http://localhost:5984/DB/_all_docs
>> 
>> I know I could put a proxy in between and block/rewrite _purge or
>> _all_docs, but is there an easier way?
>> 
>> Thanks


Re: Disable purge? Also, hide all docs?

Posted by jumbo jim <ju...@gmail.com>.
Ok so I can't disable purge..

If a user did purge... would that then replicate and delete all documents
from other servers it is replicating to?


On Wed, Dec 31, 2014 at 8:34 PM, Alexander Shorin <kx...@gmail.com> wrote:

> On Wed, Dec 31, 2014 at 9:16 AM, jumbo jim <ju...@gmail.com> wrote:
> >> The easiest way is indeed to put CouchDB behind a proxy, but for
> >> _all_docs you can just remove this http endpoint from config by adding
> >> the following in your local.ini
> >>
> >
> >
> > Thanks Alexander.
> >
> > Is it possible to remove _replicate in the same manner? It occurred to me
> > that the user could simply replicate all documents out to his own
> database
> > also. Don't need to be an admin for replication.
> >
> > If not, I suppose the proxy route I will have to go.
>
> You can remove _replicate, but it won't prevent users to replicate
> their documents since replication happens not by magic, but because of
> using public CouchDB HTTP API. You'll actually be forces to disable
> access to the document in database at all for everyone. I would
> recommend you to revisit your authorization policy and, since you
> seems not happy with exposing CouchDB as is to the world, application
> architecture, because you eventually going to have some functional
> middleware in front of CouchDB.
>
> --
> ,,,^..^,,,
>

Re: Disable purge? Also, hide all docs?

Posted by Alexander Shorin <kx...@gmail.com>.
On Wed, Dec 31, 2014 at 9:16 AM, jumbo jim <ju...@gmail.com> wrote:
>> The easiest way is indeed to put CouchDB behind a proxy, but for
>> _all_docs you can just remove this http endpoint from config by adding
>> the following in your local.ini
>>
>
>
> Thanks Alexander.
>
> Is it possible to remove _replicate in the same manner? It occurred to me
> that the user could simply replicate all documents out to his own database
> also. Don't need to be an admin for replication.
>
> If not, I suppose the proxy route I will have to go.

You can remove _replicate, but it won't prevent users to replicate
their documents since replication happens not by magic, but because of
using public CouchDB HTTP API. You'll actually be forces to disable
access to the document in database at all for everyone. I would
recommend you to revisit your authorization policy and, since you
seems not happy with exposing CouchDB as is to the world, application
architecture, because you eventually going to have some functional
middleware in front of CouchDB.

--
,,,^..^,,,

Re: Disable purge? Also, hide all docs?

Posted by jumbo jim <ju...@gmail.com>.
> The easiest way is indeed to put CouchDB behind a proxy, but for
> _all_docs you can just remove this http endpoint from config by adding
> the following in your local.ini
>


Thanks Alexander.

Is it possible to remove _replicate in the same manner? It occurred to me
that the user could simply replicate all documents out to his own database
also. Don't need to be an admin for replication.

If not, I suppose the proxy route I will have to go.

Re: Disable purge? Also, hide all docs?

Posted by Alexander Shorin <kx...@gmail.com>.
The easiest way is indeed to put CouchDB behind a proxy, but for
_all_docs you can just remove this http endpoint from config by adding
the following in your local.ini

[httpd_db_handlers]
_all_docs =

Suddenly, for _purge you cannot do the same trick. However, you might
want to open issue on JIRA about since this looks like is an unwelcome
behaviour.
--
,,,^..^,,,


On Tue, Dec 30, 2014 at 6:38 AM, jumbo jim <ju...@gmail.com> wrote:
> Hi,
>
> I don't want a particular user to be able to delete any documents - only
> create/update. I have a design doc to prevent normal deletion -
>
> function(newDoc, oldDoc, userCtx, secObj) {
>     if ( (newDoc._deleted === true) && (userCtx.roles.indexOf('_admin') ===
> -1) ) {
> throw({forbidden: 'no way!'});
>     }
>     else{
> return;
>     }
> }
>
> However, the user can still purge! Is there a way to stop this?
>
> Also, is there a way to hide all docs? ie, block this -
> http://localhost:5984/DB/_all_docs
>
> I know I could put a proxy in between and block/rewrite _purge or
> _all_docs, but is there an easier way?
>
> Thanks