-
Notifications
You must be signed in to change notification settings - Fork 157
Use of request's global cookie jar
#73
Comments
@mikeal is this an issue in request? |
I would like to have this patched in I'm still looking at your code and comments and trying to figure this out myself, so I should get back to you soon. |
I believe the problem is that nano doesn't (perhaps can't) instantiate request. This means that they all reference back to the same place (and therefore the same cookie jar). Try this out for example:
|
my 2 cents: I know that by default request uses the same cookie jar for all requests. FYI, you can construct a cookie jar in request by calling:
and you can associate it to a request like this:
if you don't want to use the cookie jar at all just pass |
I agree that this needs to be an option, however I personally believe that the default should be Its also confusing because whilst you can create separate instances of nano (and use them in isolation), the underlying request is a reference, not an instance - leading to potential confusion in the area of a jar. IMO |
nano can default to false. var request = require('request').defaults({jar:false}) |
Sorry, ignore 8a7fb4d - that was an accidental push! :) |
This looks awesome. I'll merge and review as soon as I get a free cycle! |
Updates cloudant-follow to 0.16.3 and request to 2.83
Sorry to keep firing issues at you - don't worry, I'll do a pull request for this if you agree its a problem. :)
request uses a global cookie jar, into which all response cookies are stored, and then used on subsequent requests. This behaviour is enabled by default; you have to set
jar
tofalse
to disable it.I believe that nano should always default for
jar
tofalse
.Because of the nature of nano and CouchDB, it is likely that you will doing multiple nano requests as different users (especially if you have a 1 user to 1 database set up) within a single method.
This probably hasn't been noticed before as nano hasn't had support for CouchDB's cookie authentication. But with this coming (#71), it is especially problematic having
jar
enabled by default - it means that if you have performed an action as a logged in standard user (cookie auth), and then attempt something as admin (using basic auth) - the admin request will fail - because the cookie jar sends over the auth cookie of the standard user - irrespective of whether you have isolated nano instances (because request's cookie jar is global).See this gist for an example: https://gist.github.com/2717116
It should just be a case of changing this code from:
to
The interim workaround is to do the above, by using
request_defaults
(as below), but as I see no benefit for nano in using a cookiejar
in any scenario, I think the fix above should be baked in instead.The text was updated successfully, but these errors were encountered: