Couchdb how to list all users on db?

I am trying to determine which users were created.

is there a curl command on the couch to list all existing couchdb users?

if so, what is this call?

+4
source share
2 answers

curl gets all users as documents, grep retrieves documents _id , prefix sed strips org.couchdb.user: and sorts removes duplicates that come from the result of the view:

 curl -s http://localhost:5984/_users/_all_docs | grep -o 'org.couchdb.user:[[:alnum:]]\+' | sed -n -e 's/org.couchdb.user:\(.*\)/\1/p' | sort -u 

Please note that starting from version 1.2.0, if you had the Admin Party fixed on the server, you need to transfer the CouchDB administrator credentials to make such requests for the _users database.

+6
source

Use _all_docs , the following command lists all the information about the documents of a specific database, just specify the name of the database, and then you will run:

 curl -X GET http://localhost:5984/<db_name>/_all_docs 

Then replace <db_name> with _users and use port 5986, because _users is the system table in port 5986:

 curl -X GET http://localhost:5986/_users/_all_docs 
+7
source

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


All Articles