couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r960975 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Date Tue, 06 Jul 2010 18:36:27 GMT
Author: jchris
Date: Tue Jul  6 18:36:27 2010
New Revision: 960975

URL: http://svn.apache.org/viewvc?rev=960975&view=rev
Log:
dont redirect endlessly when require_valid_user=true

Modified:
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=960975&r1=960974&r2=960975&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Tue Jul  6 18:36:27 2010
@@ -748,15 +748,20 @@ error_headers(#httpd{mochi_req=MochiReq}
                     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 ->



Mime
View raw message