[
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)