[ 
https://issues.apache.org/jira/browse/COUCHDB-1452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13615530#comment-13615530
 ] 

Nathan Vander Wilt commented on COUCHDB-1452:
---------------------------------------------

+1 on somehow whitelisting _session (and other authorization plugin handlers?) 
even when couch_httpd_auth/require_valid_user=true

I think Keith's suggested workaround (send credentials twice as Basic Auth 
header alongside previously-normal cookie requests) is a good recommendation 
against the current situation though. Basically, any code that was written to 
use CouchDB as a session store needs to be prepared for a 401 (rather than just 
null user info) back from _session queries, as well as sending the 
username/password twice when authenticating (once in headers to get past the 
require_valid_user "firewall" and again in the body for the cookie generating 
code).
                
> Can't POST /_session with require_valid_user=true (Cookie authentication)
> -------------------------------------------------------------------------
>
>                 Key: COUCHDB-1452
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1452
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.1.1
>         Environment: Fedora 16
> [root@CouchDBTest ~]# uname -a
> Linux CouchDBTest 3.3.0-8.fc16.x86_64 #1 SMP Thu Mar 29 18:37:19 UTC 2012 
> x86_64 x86_64 x86_64 GNU/Linux
>            Reporter: Seb
>
> Hello
> I'm playing with couchdb and having a small problem with authentication (I 
> would like to be cookie+https only)
> With require_valid_user, every action must be authenticated.
> Then we need to authenticate to couchdb in order to POST to /_session.
> So, if you disable classical HTTP auth, you can't authenticate users on 
> couchdb only with cookie.
> [root@CouchDBTest ~]# curl -vX POST http://localhost:5984/_session -H 
> 'Content-Type: application/x-www-form-urlencoded' -d 
> 'name=admin&password=this_is_a_test'
> * About to connect() to localhost port 5984 (#0)
> *   Trying ::1... Connection refused
> *   Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 5984 (#0)
> > POST /_session HTTP/1.1
> > User-Agent: curl/7.21.7 (x86_64-redhat-linux-gnu) libcurl/7.21.7 
> > NSS/3.13.3.0 zlib/1.2.5 libidn/1.22 libssh2/1.2.7
> > Host: localhost:5984
> > Accept: */*
> > Content-Type: application/x-www-form-urlencoded
> > Content-Length: 34
> > 
> < HTTP/1.1 401 Unauthorized
> < WWW-Authenticate: Basic realm="administrator"
> < Server: CouchDB/1.1.1 (Erlang OTP/R14B04)
> < Date: Sun, 01 Apr 2012 14:58:13 GMT
> < Content-Type: text/plain;charset=utf-8
> < Content-Length: 61
> < Cache-Control: must-revalidate
> < 
> {"error":"unauthorized","reason":"Authentication required."}
> * Connection #0 to host localhost left intact
> * Closing connection #0
> The workaround to obtain a cookie with require_valid_user=true is to 
> authenticate with classical HTTP auth then to auth again with a POST on 
> _session.
> Not POST /_session should be allowed even for require_valid_user=true ?
> Thank in advance :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to