diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-06-25 05:30:51 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-06-25 05:30:51 +0000 |
commit | 6d88c8c6d66772a1dac1d351405eff9c513d263e (patch) | |
tree | 88392cfcbae52f4cd5daab8bef491dd3d90cb4ed /src/couchdb/couch_httpd.erl | |
parent | a3886989b9e09ca5d01e18f1e39e9dae0f280530 (diff) |
make the authentication redirect URL configurable. setting it to the empty string yields the 0.11 behavior
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@957805 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r-- | src/couchdb/couch_httpd.erl | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 1049aa9d..ef930147 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -745,14 +745,19 @@ error_headers(#httpd{mochi_req=MochiReq}=Req, Code, ErrorStr, ReasonStr) -> % redirect to the session page. case ErrorStr of <<"unauthorized">> -> - % if the accept header matches html, then do the redirect. else proceed as usual. - case re:run(MochiReq:get_header_value("Accept"), "html", [{capture, none}]) of - nomatch -> - {Code, []}; - match -> - UrlReturn = ?l2b(couch_util:url_encode(MochiReq:get(path))), - UrlReason = ?l2b(couch_util:url_encode(ReasonStr)), - {302, [{"Location", couch_httpd:absolute_uri(Req, <<"/_utils/session.html?return=",UrlReturn/binary,"&reason=",UrlReason/binary>>)}]} + case couch_config:get("couch_httpd_auth", "authentication_redirect", nil) of + nil -> {Code, []}; + AuthRedirect -> + % if the accept header matches html, then do the redirect. else proceed as usual. + case re:run(MochiReq:get_header_value("Accept"), "html", [{capture, none}]) of + nomatch -> + {Code, []}; + match -> + AuthRedirectBin = ?l2b(AuthRedirect), + UrlReturn = ?l2b(couch_util:url_encode(MochiReq:get(path))), + UrlReason = ?l2b(couch_util:url_encode(ReasonStr)), + {302, [{"Location", couch_httpd:absolute_uri(Req, <<AuthRedirectBin/binary,"?return=",UrlReturn/binary,"&reason=",UrlReason/binary>>)}]} + end end; _Else -> {Code, []} |