N1ql join with another bucket that is password protected

Here is what I have:

  • 2 buckets, both of which are password protected
  • a query that has a join between these two buckets
  • Java SDK

I connect to one of the buckets, providing the password, of course. When I run the query I get an authorisation error.

I did some searching around, and people are suggesting removing the password, which is a poor solution. There has to be a better solution out there.

@vibelifeinc right now this is not supported but is on the roadmap. The reason why its not working right now is that a N1QL query is performed at the bucket level conceptually so passing credentials from multiple buckets is not possible.

We are working on a solution to that problem that works across the SDKs and aligns with future plans on RBAC on the server side too.

You can join across multiple password-protected buckets by bypassing the SDK and calling the N1QL REST API directly.

As @daschl said, the SDK team will fix the SDKs to support this.

Hi @geraldss, we’re running into the same problem here.
Do you guys know when this bug is going to fixed, which SDK version should we expect for?

Thanks.
Ron

@ronzionp @vibelifeinc in SDK 2.3.3, there is a withCredentials(String, String) method on the N1qlParams builder. Each call will add a credential login/password pair to the request, so you can call this for each password protected bucket, and it should work.

Note this is kind of experimental, as a first step preparing for a Cluster-level query API which is still in the works.

Thanks a lot. will try that.

@simonbasle appreciate your help. I get the following error while trying your suggestion:
creds has to be of type array of { user, pass } with code 1070

my implementation is as follow:
val params = N1qlParams.build() .withCredentials(BUCKET1_NAME, BUCKET1_PASS) .withCredentials(BUCKET2_NAME, BUCKET2_PASS) bucket.query(N1qlQuery.simple(MY_STATEMENT, params))

Thanks a lot.
Ron

mmh which version of Couchbase Server are you using @ronzionp?

@simonbasle yup. must be it. 4.1.0 - Thanks a lot for your help, appreciate!