Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

basic auth not working #8

Open
jmarca opened this Issue Jan 4, 2011 · 2 comments

Comments

Projects
None yet
3 participants

jmarca commented Jan 4, 2011

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."}
  });
Owner

creationix commented Jan 4, 2011

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.

michael commented Feb 27, 2011

Have a look at my fork. It should work with the patched code. michael/couch-client@011698b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment