Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-chttpd/pull/147#discussion_r83634499
  
    --- Diff: src/chttpd.erl ---
    @@ -464,12 +466,37 @@ extract_cookie(#httpd{mochi_req = MochiReq}) ->
         end.
     %%% end hack
     
    -authenticate_request(Req) ->
    -    AuthenticationFuns = [
    -        {<<"cookie">>, fun chttpd_auth:cookie_authentication_handler/1},
    -        {<<"default">>, fun chttpd_auth:default_authentication_handler/1},
    +set_auth_handlers() ->
    +    AuthenticationDefault =  "{chttpd_auth, cookie_authentication_handler},
    +      {chttpd_auth, default_authentication_handler}",
    +    AuthenticationSrcs = couch_httpd:make_fun_spec_strs(
    +        config:get("chttpd", "authentication_handlers", 
AuthenticationDefault)),
    +    AuthHandlers = lists:map(
    +        fun(A) -> {auth_handler_name(A), couch_httpd:make_arity_1_fun(A)} 
end, AuthenticationSrcs),
    +    AuthenticationFuns = AuthHandlers ++ [
             fun chttpd_auth:party_mode_handler/1 %% must be last
         ],
    +    ok = application:set_env(chttpd, auth_handlers, AuthenticationFuns).
    +
    +% SpecStr is a string like "{my_module, my_fun}"
    +% Takes the first token of the function name in front '_' as auth handler 
name
    +% e.g. 
    +% chttpd_auth:default_authentication_handler: default
    +% chttpd_auth_cookie_authentication_handler: cookie
    +% couch_http_auth:proxy_authentication_handler: proxy
    +%
    +% couch_http:auth_handler_name can't be used here, since it assumes the 
name 
    +% of the auth handler to be the 6th token split by [\\W_]
    +% - this only works for modules with exactly two underscores in their name
    +% - is not very robust (a space after the ',' is assumed) 
    +auth_handler_name(SpecStr) ->
    +    case couch_util:parse_term(SpecStr) of
    --- End diff --
    
    a case statement with only one clause seems odd.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to