User Creation Error in CouchDB 1.0

My system is ubuntu 10.04 and I have CouchDB 1.0 installed. I can create an administrator or more administrators, log in as an administrator, and everything works fine.

Starting from 0.11 in CouchDB there is the concept of users who are not admins and may have fine-grained rights to databases. I want to create such a user. I open Futon, I am not logged in, and I click the "Registration" link (lower right corner). The question then becomes about username and password. When I fill out the form and submit it, a very long error message appears in the "Username" field:

Registration error: {gen_server, call, [couch_query_servers, {get_proc, {doc, <"_ design / _auth" →, {1, [<84,165,145,147,156,145,146,42,53,239,238,7, 235, 44,58,114 →]}, {[ <<"language" →, <"javascript" →}, {<"validate_doc_update" →, <"\ n function (newDoc, oldDoc, userCtx) {\ n if ((oldDoc & oldDoc.type! == 'user' ) || newDoc.type! == 'user') {\ n throw ({forbidden: 'doc.type must be user'}); \ n} // we only allow user documents \ n \ n if (newDoc. _deleted === true) {\ n // allow deletion by administrators and corresponding users \ n // without checking other fields \ n if ((userCtx.roles.indexOf ('_ admin')! == -1) || \ n (userCtx.name == oldDoc.name)) {\ n return; \ n} else {\ n throw ({forbidden: "Only admins can delete other user documents cops..)); \ n} \ n} \ n \ n if (! newDoc.name) {\ n throw ({forbidden: 'doc.name required'}); \ n} \ n \ n if ( ! (newDoc.roles && (typeof newDoc.roles.length! == 'undefined'))) {\ n throw ({forbidden: 'doc.roles must be an array'}); \ n} \ n \ n if ( newDoc._id! == ('org.couchdb.user:' + newDoc.name)) {\ n throw ({\ n forbidden: 'Doc ID must be of the form org.couchdb.user: name' \ n}); \ n} \ n \ n if (oldDoc) {// check for all updates \ n if (oldDoc.name! == newDoc.name) {\ n throw ({forbidden: "Usernames cannot be changed".}); \ n } \ n} \ n \ n if (newDoc.password_sha && &!! newDoc.salt) {\ n throw ({\ n forbidden: "Users with the password_sha must have a salt". + \ n 'See / _ utils / script /couch.js, for example, code. '\ n}); \ n} \ n \ n if (userCtx.roles.indexOf (' _ admin ') === -1) {\ n if (oldDoc) {/ / check for updates without administrator \ n if (userCtx.name! == newDoc.name) {\ n throw ({\ n forbidden: 'You can update your own custom document. \ n}); \ n} \ n // check for role updates \ n var ol dRoles = oldDoc.roles.sort (); \ n var newRoles = newDoc.roles.sort (); \ n \ n if (oldRoles.length! == newRoles.length) {\ n throw ({forbidden: "_admin only can edit roles "}); \ n} \ n \ n for (var i = 0; i <oldRoles.length; i ++) {\ n if (oldRoles [i]! == newRoles [i]) {\ n throw ({forbidden: 'Only _admin can edit roles'}); \ n} \ n} \ n} else if (newDoc.roles.length> 0) {\ n throw ( {forbidden: "Only the administrator can install roles"}); \ n} \ n} \ n \ n // there are no system roles in db \ n for users (var i = 0; i <newDoc.roles.length; i + +) {\ n if (newDoc.roles [i] [0] == = '') {\ n throw ({\ n forbidden: \ n 'There are no system roles (starting with underscore) in db users.' \ n }); \ n} \ n} \ n \ n // there are no system names as names \ n if (newDoc.name [0] === '_') {\ n throw ({forbidden: "Username cannot begin with an underscore. "};) \ n} \ n} \ n" →}]}, [], false, []}, {<"_ design / _auth" →, <1-54a591939c91922a35efee07eb2c3a72 "→}}] }

What is it? How to create users in CouchDB?

+4
source share
3 answers

To create a user, drag the JSON document to http://localhost:5984/_users/org.couchdb.user:<username>

For example, create a login.json file as follows:

 { "_id": "org.couchdb.user:test", "name": "test", "password_sha": "24e8e07c23d8ae85108468ec4814b2f0fa84edde", "salt": "78f67e252351a56d6e1e6df9ba005239", "roles": [], "type": "user" } 

Then output the data to couchdb:

 curl -X PUT http://<admin>:<password>@localhost:5984/_users/org.couchdb.user%3Atest -S -s -H "Content-Type: application/json" -d @login.json 

(Replace <admin> and <password> your couchdb credentials.)

Now you can log in to couchdb using the user "test" and the password "test123".

+5
source

I had a similar error on debian. I compiled CouchDB from the build-couchdb repository. I could create administrators, but not regular users. I also failed to run temporary views. Solved it by clearing libmozjs1d and erlang-nox and recompiling. hope this helps.

+2
source

It looks like you already have an administrator account on the system that CouchDB detects and expects you to log in to create accounts. Check the local.ini configuration file to see if you have admins defined in the [admins] section. You probably have some specific ones if you are upgrading an old installation.

Log in as one of these administrators or change your password if you do not remember it (just replace it with your text password and it will be hashed the next time you start CouchDB). Now restart CouchDB. If you have an administrator account, log in as this user or delete all old accounts, then click "Register" to create a new one.

Greetings.

+1
source

All Articles