Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB create a server admin via script

this seems simple enough but I've search all over and I can't seem to be able to create server admin users in CouchDB. I can create regular users, but can't figure out how to create one from a script. Can someone demonstrate doing this with curl?

Just to clarify, by server admin user I mean a user who's info is store in the local.ini. In Futon you can login as an admin, click setup more admins, and then create them, but I can't figure out how to replicate this functionality. I've even stepped through what's happening in the jquery couch plugin when I create a new admin in Futon but I can't see what I'm doing wrong. All of the users I add via script just get put in _users table but not in the local.ini. Thanks!

like image 666
skinneejoe Avatar asked Mar 23 '23 08:03

skinneejoe


2 Answers

According to the documentation, you can create a new admin via the REST API by working with the _config endpoint.

By issuing a PUT request against /_config/admins/:username (where the request body is the password) a new admin will be created. (provided you have access to do so)

Futon is just using $.couch.config({...ajax options...}, "admins", username, password); to accomplish this.

like image 56
Dominic Barnes Avatar answered Mar 29 '23 00:03

Dominic Barnes


As per http://guide.couchdb.org/draft/security.html, you can use something like:

$ curl -X PUT localhost:5984/_config/admins/myusername -d '"mypassword"'
like image 44
redgeoff Avatar answered Mar 29 '23 01:03

redgeoff