Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 70189 invoked from network); 30 Apr 2010 23:35:52 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Apr 2010 23:35:52 -0000 Received: (qmail 74477 invoked by uid 500); 30 Apr 2010 23:35:51 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 74444 invoked by uid 500); 30 Apr 2010 23:35:51 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 74436 invoked by uid 99); 30 Apr 2010 23:35:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Apr 2010 23:35:51 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bharat.kjsce@gmail.com designates 209.85.221.191 as permitted sender) Received: from [209.85.221.191] (HELO mail-qy0-f191.google.com) (209.85.221.191) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Apr 2010 23:35:43 +0000 Received: by qyk29 with SMTP id 29so969328qyk.14 for ; Fri, 30 Apr 2010 16:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=jSpZWn48CGa+Fr+dORdgszvGJ9yITKL04BFXQhM5Xss=; b=Wj9+nIUP7oSctcIWuQLOvDROuiiyjArEPS10OHSBeizx7Wb43Eof9570rakEeLrMDl auX4g65hNI2Bmoxf7Y67c0I+XJQipcm02B4tLC2BQL2ljOkDin0ZHBp3+Rb6Ix7js9HF 08WzUkXXdb/Sj54BQQN+lZtsFAMqbuzl2/YgY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=voadI2Q4SJ2VETFjy6qnC+WLfCa46Kfb6pMCf3LKA7VPExCCbqg7sI4YEXlObu0UwK 56jQb35cImbg53HC5WwXpuBeJsy/L4j3Ctf9Lc5l6g5/YnswqqMr9+skdjpqZuz779HJ nM8qAtVc6x0Ft/sKdJi0cKk+0Qmd09QSRHBpI= MIME-Version: 1.0 Received: by 10.229.73.135 with SMTP id q7mr633417qcj.41.1272670522760; Fri, 30 Apr 2010 16:35:22 -0700 (PDT) Received: by 10.229.229.66 with HTTP; Fri, 30 Apr 2010 16:35:22 -0700 (PDT) In-Reply-To: References: <20100428200008.GC28028@translab.its.uci.edu> Date: Fri, 30 Apr 2010 16:35:22 -0700 Message-ID: Subject: Re: jcouchdb anyone? From: Bharat To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016364ee0ec6cdfaf04857cb211 X-Virus-Checked: Checked by ClamAV on apache.org --0016364ee0ec6cdfaf04857cb211 Content-Type: text/plain; charset=ISO-8859-1 back to this. Looks like authentication works for mostly all other requests but not replication which is using a HttpPost object. Anyone seeing this behavior? Again pretty striaght fwd code, using the same auth (after killing my login ServerImpl instance): ServerImpl service = new ServerImpl(sourceUrl); Credentials credentials = new UsernamePasswordCredentials("username", "password"); AuthScope authScope = new AuthScope(sourceUrl, port, "_admin"); service.setCredentials(authScope, credentials); ReplicationInfo repInfo = service.replicate(sourceDbName, targetDbName, false); ---------------------- I see this in the logs: [debug] [<0.2228.0>] 'POST' /_replicate {1,1} Headers: [{'Connection',"Keep-Alive"}, {'Content-Encoding',"UTF-8"}, {'Content-Length',"44"}, {'Content-Type',"application/json"}, {'Host',"localhost:5984"}] [debug] [<0.2228.0>] OAuth Params: [] [debug] [<0.2246.0>] Not a reader: UserCtx {user_ctx,null,[],undefined} vs Names [<<"username">>] Roles [<<"_admin">>] [error] [<0.2246.0>] {error_report,<0.30.0>, {<0.2246.0>,crash_report, [[{initial_call,{couch_rep,init,['Argument__1']}}, {pid,<0.2246.0>}, {registered_name,[]}, {error_info, {exit, {bad_return_value, {unauthorized, <<"You are not authorized to access this db.">>}}, [{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}}, {ancestors, [couch_rep_sup,couch_primary_services,couch_server_sup,<0.31.0>]}, {messages,[]}, {links,[<0.80.0>]}, {dictionary,[]}, {trap_exit,true}, {status,running}, {heap_size,987}, {stack_size,24}, {reductions,326}], []]}} =CRASH REPORT==== 30-Apr-2010::16:28:14 === crasher: initial call: couch_rep:init/1 pid: <0.2246.0> registered_name: [] exception exit: {bad_return_value, {unauthorized, <<"You are not authorized to access this db.">>}} in function gen_server:init_it/6 ancestors: [couch_rep_sup,couch_primary_services,couch_server_sup, <0.31.0>] messages: [] links: [<0.80.0>] dictionary: [] trap_exit: true status: running heap_size: 987 stack_size: 24 reductions: 326 neighbours: [error] [<0.2228.0>] Uncaught error in HTTP request: {error, {case_clause, {error, {bad_return_value, {unauthorized, <<"You are not authorized to access this db.">>}}}}} [info] [<0.2228.0>] Stacktrace: [{couch_rep,start_replication_server,1}, {couch_rep,replicate,2}, {couch_httpd_misc_handlers,handle_replicate_req,1}, {couch_httpd,handle_request_int,5}, {mochiweb_http,headers,5}, {proc_lib,init_p_do_apply,3}] [info] [<0.2228.0>] 127.0.0.1 - - 'POST' /_replicate 500 [debug] [<0.2228.0>] httpd 500 error response: {"error":"case_clause","reason":"{error,\n {bad_return_value,\n {unauthorized,<<\"You are not authorized to access this db.\">>}}}"} ------------------------------------ On Wed, Apr 28, 2010 at 1:09 PM, Bharat wrote: > Perfect James. > Thats what I was missing. Uncommenting WWW-authenticate and passing that as > a realm, works. > > Thanks guys. > > On Wed, Apr 28, 2010 at 1:00 PM, James Marca wrote: > >> Perhaps try passing the "authority" key when setting the AuthScope? >> >> Example: >> >> my /etc/couchdb/local.ini has: >> >> ... >> [httpd] >> ; Uncomment next line to trigger basic-auth popup on unauthorized >> requests. >> WWW-Authenticate = Basic realm="administrator" >> ... >> >> >> My code in a test case looks as follows: >> >> >> ... >> private static final String TESTDB_AUTHORITY = "administrator"; >> ... >> >> @Before >> public void setUp() throws Exception { >> // load couchdb properties >> >> props.load(getClass().getClassLoader().getResource(DB_PROPERTIES).openStream()); >> >> ... >> >> dbname =props.getProperty("couchdb.db.dbname",TESTDB_NAME); >> user =props.getProperty("couchdb.db.user"); >> pass =props.getProperty("couchdb.db.password"); >> authority >> =props.getProperty("couchdb.db.authority",TESTDB_AUTHORITY); >> >> ... >> } >> >> >> >> then later, I create dbs as follows...note the authority in AuthScope new >> call >> >> public static Database createDatabaseForTest() >> { >> // Load couchdb properties >> Server server = new ServerImpl(host,port); >> if(user != null && pass !=null) { >> AuthScope as = new AuthScope(host, port, authority); >> Credentials c = new UsernamePasswordCredentials(user, pass); >> server.setCredentials(as,c); >> } >> >> List databases = server.listDatabases(); >> >> log.debug("databases = " + databases); >> >> ... >> >> } >> >> Hope that helps, >> James >> >> >> >> On Wed, Apr 28, 2010 at 10:33:31AM -0700, Bharat wrote: >> > I am trying to use jcouchdb api for authenticating against my couchdb >> > instance(0.11). I have set the admin usr/pass in futon and in addition >> > specified ADMIN and READER on the DB I am trying to access so only >> people >> > with correct credentials can access/view the DB. >> > >> > My code is pretty simple and directly using ServerImpl and its >> > setCredentials and get method: >> > >> > ------------------------- >> > ServerImpl service = new ServerImpl("localhost"); >> > Credentials credentials = >> > new UsernamePasswordCredentials(, ); >> > AuthScope authScope = new AuthScope("http://localhost", 5984); >> > >> > service.setCredentials(authScope, credentials); >> > >> > Response res = service.get(/); >> > ----------------------------- >> > >> > But everytime I do this, I keep getting http 401 in my response. Is >> there >> > something I am missing or not setting correctly? >> > >> > I know its not exactly a couchdb question but there is very little to no >> > documentation available so thought I ll try here. >> > >> > Thanks! >> >> -- >> This message has been scanned for viruses and >> dangerous content by MailScanner, and is >> believed to be clean. >> >> > --0016364ee0ec6cdfaf04857cb211--