creationix / couch-client

A minimal CouchDB client that easy and powerful
MIT License
101 stars 9 forks source link

Beyond Basic Auth Bugs #11

Closed steelThread closed 13 years ago

steelThread commented 13 years ago

Hey guys,

I too have been trying to work with couchone and here 's what I've found out when using couch-client with node v0.3.x. First using the ftp style credential passing on the url simply doesn't work. What happens is the parsed uri.host includes the credentials which in turn gets added as the 'host' header. Resulting response body is 'Host not found' but this is getting hidden and couch-client simply errors out. I didn't spend a lot of time finding the exact line but I think this is when the client is trying to JSON.parse the body for the callback. Solution is to use 'hostname' field of the parsed uri. Seems pretty redundant to specify this on the http.createClient call too.

The second issue is that in order to pass the credentials along, the authorization header needs to be set. The parsed uri still has an 'auth' field so this should be simple to add. It does seems a little odd and disjoint to me that, from an API perspective, this form of credential passing is supported by url parser but not natively supported by the http client.

Finally, and this is a show stopper, I have made the appropriate changes to the code so i can at least use basic auth with my couchone app. The big problem is that TLS (SSL) is not currently working in node v0.3.x for http clients, at least I can't get it to work. I think the server stuff was recently reworked and the client stuff is coming soon. Of course none of the .3.x versions are marked as stable so keeping up with the bleeding edge right now is somewhat futile and very frustrating.

In any case I just wanted to pass this along in case others are running into similar issues. I'd submit a pull request but seeing how the solution (only) allows you to pass your credentials over an unsecured channel I don't think any one of us would want to promote such usage. I'll watch for node updates and once the client stuff stabilizes I'll work up a patch and submit it then if someone doesn't get to it beforehand.

later

michael commented 13 years ago

Based on your updates I did a number of fixes today . Could you check if my fork is still working with https/Couchone?

Cheers, Michael

steelThread commented 13 years ago

Michael,

Just sent you a pull request to augment the changes you have made in your fork. Changes includes a tiny bit of cleanup and a new unit test to cover the 'request' method which exercises the basic-auth support against the local fixture database. It would be great to get these changes incorporated into yours to have a comprehensive pull request.

sT

steelThread commented 13 years ago

bugging out.