apache / couchdb

Seamless multi-master syncing database with an intuitive HTTP/JSON API, designed for reliability
https://couchdb.apache.org/
Apache License 2.0
6.27k stars 1.03k forks source link

CouchDB v3.4.1 return 403 on GET /_session with a wrong password #5315

Open H--o-l opened 1 month ago

H--o-l commented 1 month ago

Description

This morning I upgraded one node of my CouchDB cluster node to v3.4.1 while the two other nodes of the cluster are still on CouchDB v3.3.3.

Since then, I have had multiple exceptions on my backend related to users using the wrong password and CouchDB returning an HTTP status 403 instead of the usual HTTP status 401.

Usually, I catch the 401 to return a nice message to users so they can understand what's wrong. But since the update, for some users (not all users and I don't know why on these users specifically) CouchDB returns an unexpected 403 on the GET /_session. This has pushed me to create a temporary urgent release where I catch both the 401 and the 403 to return a nice error in both cases.

The CouchDB documentation for v3.4.1 is explicit: the route should only return HTTP 200 or HTTP 401, not HTTP 403.

Steps to Reproduce

I don't know for sure, I wasn't able to code a reproducer, it happens only on my production servers. There is something on the production cluster that makes the case appear:

Expected Behaviour

GET /_session should always return HTTP 200 or HTTP 401, never HTTP 403.

Your Environment

Additional Context

I don't know, you tell me!

iilyak commented 1 month ago

This is a feature added recently https://github.com/apache/couchdb/blob/main/rel/overlay/etc/default.ini#L1074. Probably the API docs need to be updated.

\cc @rnewson

rnewson commented 1 month ago

agree, the docs need updating. what a chore :(

H--o-l commented 1 month ago

OK, understood, thanks. What about the changelog, did the change appear inside it? Because I read it carefully before doing the update and I haven't noticed that change. It would have avoided inconvenience for my users if I had been able to notice it before the update.

rnewson commented 1 month ago

The new lockout support was documented in the changelog (https://docs.couchdb.org/en/stable/whatsnew/3.4.html), but we (I) didn't update the api docs to list 403 as a possibility for all endpoints, we'll sort that out.

H--o-l commented 1 month ago

OK, my bad, thanks for the answer. I let you see then, and you can close the issue when you want :+1: