Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

401 from Cloudant when require_valid_user=true #409

@smhdfdl

Description

@smhdfdl

Please read these guidelines before opening an issue.

Bug Description

Two related problems.

Switching on require_valid_user=true has stopped our clients connecting to Cloudant via the client library in this repo. The POST _session call always returns a 401, despite the correct username and password being provided (in the url or as separate params). A CURL equivalent works ok and returns 200. Here is the code for our call.

that.cloudantInit({ url: CDB_URL, plugins: cloudantRequestRetry }, function (err, cloudant) {...})

Given that CURL works, it must be something the client is doing. Note that we do not provide cookieauth as a plugin. However, when we switched on client debug, we could see that the cookieauth plugin was always being added, whatever value we specified for the plugins parameter (a function, empty array, omitted). It turns out that the following line of code is always executed, and is what is adding cookieauth...

https://github.com/cloudant/nodejs-cloudant/blob/master/cloudant.js#L300

This is in contradiction to the readme. When that line is disabled, clients connect ok with 200. But are unable to take advantage of session cookies.

So two problems:

  1. cookieauth is always added, no way to stop that.
  2. When cookieauth is added, clients get 401 when require_valid_user=true.

Catch-22.

We are approaching a code ship deadline, so urgently need a resolution to 1) and preferably 2) as well.

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

Set require_valid_user=true in Cloudant .ini file, start Cloudant, connect using the client, do not specify cookieauth plugin.

2. What you expected to happen

The client should connect with 200.

3. What actually happened

Client gets 401.

Environment details

  • Version(s) that are affected by this issue.

    4.2.2

  • Node.js version

    10.15

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions