Search code examples
curlcouchdbadmincouchdb-futon

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!


Solution

  • 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.