couch-client
couch-client copied to clipboard
basic auth not working
When trying to create a db with this client, I get {"error":"unauthorized","reason":"You are not a server admin."}
I scanned the code and didn't see anything resembling setting auth headers, even though some of the examples/tests included user:pass@host:port type url strings.
(felixge / node-couchdb works for me, but he's not maintaining anymore...)
My snippet of code that fails follows. user and pass are valid admin, and the couchdb is set to require authentication (not in admin party mode). Also, the database does not yet exist
var url_obj = {'host':user+':'+pass+'@'+host,
'port':port,
'pathname':"/"+dbname };
var url_string = formatUrl(url_obj);
console.log ('url string is '+ url_string);
var cdb = CouchClient(url_string);
cdb.request('PUT',"/"+dbname, function(e,r){
if(e) console.log('e is '+JSON.stringify(e)); // does not trigger0
console.log('r is '+JSON.stringify(r));
// prints:
// {"error":"unauthorized","reason":"You are not a server admin."}
});
Hmm, I thought it used to work, maybe it was a node api change. Either way, you're more than welcome to send a patch to fix this. Basic auth is really simple, but needs to be used over ssl. I haven't yet figured out digest auth.
Have a look at my fork. It should work with the patched code. https://github.com/michael/couch-client/commit/011698b10a5d21ab43d86aa277884f92b48e24ed