Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF9A01035C for ; Wed, 22 Jan 2014 03:38:32 +0000 (UTC) Received: (qmail 43691 invoked by uid 500); 22 Jan 2014 03:38:24 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 43514 invoked by uid 500); 22 Jan 2014 03:38:22 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 43458 invoked by uid 99); 22 Jan 2014 03:38:19 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jan 2014 03:38:19 +0000 Date: Wed, 22 Jan 2014 03:38:19 +0000 (UTC) From: "Adam Kocoloski (JIRA)" To: dev@couchdb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COUCHDB-2034) authentication_handlers does not accept complex arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-2034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13878213#comment-13878213 ] Adam Kocoloski commented on COUCHDB-2034: ----------------------------------------- Wow, after seeing how much work the codebase does to establish a name for each of these handlers I really wish we would have done something like the following in the config {code} [httpd.authentication_handlers] basic = {couch_httpd_auth, default_authentication_handler} cookie = {couch_httpd_auth, cookie_authentication_handler} oauth = {couch_httpd_oauth, oauth_authentication_handler} my_auth = {my_mod, my_fun, [ { one, two }, { three, four } ] } {code} On a related note, it's not clear to me where {{#user_ctx.handler}} gets used. That code calls the auth_name function which does yet another regex on the spec string to try to come up with a unique name for the handler. I'll see what I can do to fix the current bug but I may also submit a separate patch to support the config section version. > authentication_handlers does not accept complex arguments > --------------------------------------------------------- > > Key: COUCHDB-2034 > URL: https://issues.apache.org/jira/browse/COUCHDB-2034 > Project: CouchDB > Issue Type: Bug > Reporter: Daniel Moore > > I have written a custom authentication handler for couch, but when I use the "SpecArg" syntax with embedded tuples, I get parse errors spinning up the server. For instance, a config like: > {code} > [httpd] > authentication_handlers = {my_mod, my_fun, [ { one, two }, { three, four } ] } > {code} > Gives: > {code} > [error] [<0.93.0>] {error_report,<0.30.0>, > {<0.93.0>,supervisor_report, > [{supervisor,{local,couch_secondary_services}}, > {errorContext,start_error}, > {reason, > {'EXIT', > {{case_clause, > {error, > {1,erl_parse,["syntax error before: ","'.'"]}}}, > [{couch_httpd,make_arity_1_fun,1, > [{file,"couch_httpd.erl"},{line,200}]}, > {couch_httpd,'-set_auth_handlers/0-fun-0-',1, > [{file,"couch_httpd.erl"},{line,194}]}, > {lists,map,2,[{file,"lists.erl"},{line,1224}]}, > {couch_httpd,set_auth_handlers,0, > [{file,"couch_httpd.erl"},{line,193}]}, > {couch_httpd,start_link,2, > [{file,"couch_httpd.erl"},{line,130}]}, > {supervisor,do_start_child,2, > [{file,"supervisor.erl"},{line,310}]}, > {supervisor,start_children,3, > [{file,"supervisor.erl"},{line,293}]}, > {supervisor,init_children,2, > [{file,"supervisor.erl"},{line,259}]}]}}}, > {offender, > [{pid,undefined}, > {name,httpd}, > {mfargs,{couch_httpd,start_link,[]}}, > {restart_type,permanent}, > {shutdown,brutal_kill}, > {child_type,worker}]}]}} > {code} > This seems to be as a result of [using a regex|https://github.com/apache/couchdb/blob/master/src/couchdb/couch_httpd.erl?source=c#L224-L225] to split the tuples. Perhaps we could change the strategy to wrapping the string with "\[" and "\]" and parsing it altogether? -- This message was sent by Atlassian JIRA (v6.1.5#6160)