$ curl -X GET "http://admin:pass@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/" | jq .
{
"port": "5986",
"max_http_request_size": "4294967296",
"bind_address": "127.0.0.1",
"allow_jsonp": "false",
"enable_cors": "false",
"socket_options": "[{sndbuf, 262144}]",
"authentication_handlers": "{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}",
"secure_rewrites": "true",
"enable_xframe_options": "false"
}
In this state, loading http://admin:pass@localhost:5984/_utils
will not let you use basic auth.
$ curl -X PUT "http://admin:pass@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/WWW-Authenticate" -d
'"Basic realm=\"administrator\""' -H "Content-Type: application/json"
$ curl -X GET "http://admin:pass@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/" | jq .
{
"port": "5986",
"max_http_request_size": "4294967296",
"bind_address": "127.0.0.1",
"allow_jsonp": "false",
"enable_cors": "false",
"socket_options": "[{sndbuf, 262144}]",
"WWW-Authenticate": "Basic realm=\"administrator\"",
"authentication_handlers": "{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}",
"secure_rewrites": "true",
"enable_xframe_options": "false"
}
In this state, loading http://admin:pass@localhost:5984/_utils
will let you use basic auth, as expected.
Done by selecting "Quit Apache CouchDB" from the system tray dropdown.
Once it's booted again, we can check config:
$ curl -X GET "http://admin:pass@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/" | jq .
{
"port": "5986",
"max_http_request_size": "4294967296",
"www-authenticate": "Basic realm=\"administrator\"",
"bind_address": "127.0.0.1",
"allow_jsonp": "false",
"enable_cors": "false",
"socket_options": "[{sndbuf, 262144}]",
"authentication_handlers": "{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}",
"secure_rewrites": "true",
"enable_xframe_options": "false"
}
Note that WWW-Authenticate
got saved (or possibly loaded) as www-authenticate
. Note also that this option doesn't work: we cannot use basic auth to log in.
For us to use basic auth we have to once again push the setting, with the correct case:
$ curl -X PUT "http://admin:pass@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/WWW-Authenticate" -d
'"Basic realm=\"administrator\""' -H "Content-Type: application/json"
$ curl -X GET "http://admin:pass@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/" | jq .
{
"port": "5986",
"max_http_request_size": "4294967296",
"www-authenticate": "Basic realm=\"administrator\"",
"bind_address": "127.0.0.1",
"allow_jsonp": "false",
"enable_cors": "false",
"socket_options": "[{sndbuf, 262144}]",
"WWW-Authenticate": "Basic realm=\"administrator\"",
"authentication_handlers": "{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}",
"secure_rewrites": "true",
"enable_xframe_options": "false"
}
Note we now have both :-)