Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require auth on login attempts #2321

Merged
merged 2 commits into from
Nov 21, 2019

Conversation

kocolosk
Copy link
Member

Overview

Previously with require_valid_user=true configured a user would need to supply Basic auth credentials in order to login via the _session endpoint (or have some otgher Catch-22 way of using an existing session). This patch makes it so that any attempt to POST to _session is allowed to proceed.

Testing recommendations

Try to POST to _session with require_valid_user = true and don't supply any additional basic auth header. Without this patch you would get rejected.

Related Issues or Pull Requests

Closes #1947.

Checklist

Previously with require_valid_user=true configured a user would need to
supply Basic auth credentials in order to login via the _session
endpoint (or have some otgher Catch-22 way of using an existing
session). This patch makes it so that any attempt to POST to _session
is allowed to proceed.

Closes #1947.
Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 curl -v http://127.0.0.1:5984/_session -H 'Content-Type:application/x-www-form-urlencoded' -d 'name=adm&password=pass'
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> POST /_session HTTP/1.1
> Host: 127.0.0.1:5984
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type:application/x-www-form-urlencoded
> Content-Length: 22
>
* upload completely sent off: 22 out of 22 bytes
< HTTP/1.1 200 OK
< Cache-Control: must-revalidate
< Content-Length: 44
< Content-Type: application/json
< Date: Thu, 21 Nov 2019 19:16:20 GMT
< Server: CouchDB/3.0.0-8904f6f0f (Erlang OTP/21)
< Set-Cookie: AuthSession=YWRtOjVERDZFMjg1OqrvTS-Z7L8h67Pe8lE3hvHH4y5R; Version=1; Expires=Thu, 21-Nov-2019 19:26:21 GMT; Max-Age=600; Path=/; HttpOnly
<
{"ok":true,"name":"adm","roles":["_admin"]}

curl -s  --cookie AuthSession=YWRtOjVERDZFMjg1OqrvTS-Z7L8h67Pe8lE3hvHH4y5R  -H "X-CouchDB-WWW-Authenticate: Cookie" http://127.0.0.1:5984/_node/_local/_config/chttpd | jq
{
  "max_db_number_for_dbs_info_req": "100",
  "port": "5984",
  "prefer_minimal": "Cache-Control, Content-Length, Content-Range, Content-Type, ETag, Server, Transfer-Encoding, Vary",
  "backlog": "512",
  "socket_options": "[{sndbuf, 262144}, {nodelay, true}]",
  "require_valid_user": "true",
  "server_options": "[{recbuf, undefined}]",
  "bind_address": "127.0.0.1"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cookie-only, no-basic-auth "require_valid_user=true" (except for /_session)
2 participants