You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/03/22 04:34:44 UTC

[GitHub] [couchdb] nickva commented on issue #1986: Unable to query /database/_all_docs as non server-admin

nickva commented on issue #1986: Unable to query /database/_all_docs as non server-admin
URL: https://github.com/apache/couchdb/issues/1986#issuecomment-475491037
 
 
   @magnadoodle, @wohali is right, `_replicator` is special. 
   
   The idea was that `_replicator` in CouchDB 1.x could only be a single database per server. So in the case with multiple users, one of them could list the replicator doc for all the other users and view their credentials.
   
   However there is another feature in 2.x that lets you bypass this in a way. It turns out, in CouchDB 2.x you can have multiple replicator dbs! Basically any database that ends with the `/_replicator` will be a `_replicator`. For example `other/_replicator` or `my/_replicator`, etc. And it turns out those additional replicator dbs don't have this restriction that only server admin can perform `_all_docs`!
   
   Let's try it out:
   
   ```
   $ curl -XPUT http://adm:pass@localhost:15984/other%2f_replicator
   {"ok":true}
   ```
   [!] Notice: I urlencoded `/` as `%2f` so it is not interpreted as db=`other` and doc=`_replicator`
   
   Then I followed the same steps as you to add the test user. And then add the new user to `_replicator` and `other/_replicator` as admins.
   
   ```
   $ curl http://adm:pass@localhost:15984/_replicator/_security
   {"admins":{"names":["testuser"],"roles":[]},"members":{"names":[],"roles":[]}}
   
   $ curl http://adm:pass@localhost:15984/other%2f_replicator/_security
   {"admins":{"names":["testuser"],"roles":[]},"members":{"names":[],"roles":[]}}
   ```
   
   Now notice that I can't query `_all_docs` on `_replicator` but can on `other/_replicator`.
   
   ```
   $ curl http://testuser:test1234@localhost:15984/_replicator/_all_docs
   {"error":"unauthorized","reason":"You are not a server admin."}
   
   
   $ curl http://testuser:test1234@localhost:15984/other%2f_replicator/_all_docs
   {"total_rows":1,"offset":0,"rows":[
   {"id":"_design/_replicator","key":"_design/_replicator","value":{"rev":"1-85a961d0d9b235b7b4f07baed1a38fda"}}
   ]}
   ```
   
   
   
   
   Now when using / in the URL you'd have to escape it.`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services