diff options
-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 ef930147..079b9367 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -748,15 +748,20 @@ error_headers(#httpd{mochi_req=MochiReq}=Req, Code, ErrorStr, ReasonStr) -> 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 -> + case couch_config:get("couch_httpd_auth", "require_valid_user", "false") of + "true" -> {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>>)}]} + _False -> + % 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 end; _Else -> |