Skip to content

r.http is not passing back cookies sent during digest authentication #3469

Closed
enterstudio/rethinkdb
#26

Description

@larkost

There has been some back-and-forth in the tests about whether cookies are required during digest authentication. Put simply here is what is happening:

  1. r.http connects to the server
  2. the server responds with a 401 response with the auth-request headers, adding in a cookie header
  3. r.http follows through on the auth-request properly, but does not send back the cookie from step 2
  4. httpbin checks for the cookie, and sends back a 401 code.

Part of the lack of clarity has been both that httpbin is currently indiscriminate when it checks for cookies that it set, so we have been working around this by always sending cookies (both steps 1 and 3), and so there is some cookie on step 3, making httpbin happy. The issue in for httpbin is postmanlabs/httpbin#124

My guess is that we are not specifically turning on libcurl's cookie jar for the session, and so it is not doing this correctly. This might be as easy as just enabling that if we already have the concept of a session, although it might get more complicated if r.http sessions can bounce around among the worker processes.

Note that I am keeping the work-around in the tests for the moment.

Activity

  1. danielmewes commented on Dec 23, 2014

    @danielmewes
    Member

    Ping @Tryneus. Would we use a single session for this sequence of requests?

    It seems that the way to enable the cookie engine in libcurl without having to specify a path for permanently storying them is through the CURLOPT_COOKIEFILE flag:
    http://curl.haxx.se/libcurl/c/CURLOPT_COOKIEFILE.html

    Given an empty or non-existing file or by passing the empty string ("") to this option, you can enable the cookie engine without reading any initial cookies.

    Maybe it would be enough to set that option?

  2. added this to the subsequent milestone on Dec 23, 2014
  3. Tryneus commented on Dec 23, 2014

    @Tryneus
    Member

    @danielmewes, it would be pretty easy to enable this, but at the moment we do not share cURL sessions across requests. For example, when performing depagination, each subsequent request will be sent to an arbitrary worker process, authenticate using a new CURL* handle, and thus have its own set of cookies.

    This is still probably better than what we do now, considering some servers may require cookies.

  4. self-assigned this
    on Dec 23, 2014
  5. Tryneus commented on Jan 5, 2015

    @Tryneus
    Member

    This has been fixed and merged into next in commits daa6031 (cookies in a single r.http session) and 4621c45 (saving and restoring cookies across multiple workers for multiple-request r.http). Review was 2419. Will be in release 1.16.

  6. modified the milestones: , subsequent on Jan 5, 2015
  7. modified the milestones: , 1.16 on Jan 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions