Force QueryClient to use HTTP Auth for N1QL queries

Description

Temp fix for:

Note that QueryRequest.AddCredentials will not work until is resolved. This fix will use the credentials passed into Cluster.OpenBucket(user, pass) as the N1QL query credentials, adding them to the HTTP header, and sent the server.

  • If the bucket name in the query does not match the the bucket that was opened and auth'd, then the query will failed with "Authorization Failed"

  • If you try to use QueryRequest.AddCredentials, you will receive "creds has to be of type array of { user, pass }"

Once is released as a server fix, AddCredentials will work for all versions of the server in which the fix applies-for server versions 4.0.0, etc this work around will apply.

Environment

None

Gerrit Reviews

None

Release Notes Description

None

Attachments

3

Activity

Show:

Jeff Dillon December 28, 2015 at 7:44 PM

I have confirmed that the 2.2.2.5 VF works as expected for both sync and async query requests on a password protected bucket.

Jeffry Morris December 16, 2015 at 12:25 AM
Edited

See attached VF for both async and sync query requests using authenticated buckets.

Jeffry Morris December 15, 2015 at 10:11 PM

-

>>Would QueryAsync work any differently compared to Query?

Just validated that this is the case, will post a patch ASAP. In meantime, the async version works as expected and the customer could use that version.

-Jeff

Jeff Dillon December 15, 2015 at 9:56 PM
Edited

The code I provided (using 2.2.2.2) is giving the error as mentioned. I'm not using AddCredentials (it's commented out, as shown). This is against 4.0.0. Would QueryAsync work any differently compared to Query? The customer is using the Query (sync) version. I will also test with QueryAsync.

Jeffry Morris December 15, 2015 at 8:14 PM

-

Which server version are you testing against?

Note that this won't work:

However, this will work:

Note, it might make sense to change the implementation of AddCredentials temporarily so that it only accepts one user/pass combo and pushes them onto the HTTP header, overwriting the bucket user/pass that the SDK is currently using.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created December 4, 2015 at 10:31 PM
Updated January 14, 2016 at 2:08 AM
Resolved December 28, 2015 at 7:44 PM
Instabug