]> git.kaiwu.me - nginx.git/commitdiff
Fixed "satisfy any" if 403 is returned after 401 (ticket #285).
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 18 Oct 2013 14:13:49 +0000 (18:13 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 18 Oct 2013 14:13:49 +0000 (18:13 +0400)
The 403 (Forbidden) should not overwrite 401 (Unauthorized) as the
latter should be returned with the WWW-Authenticate header to request
authentication by a client.

The problem could be triggered with 3rd party modules and the "deny"
directive, or with auth_basic and auth_request which returns 403
(in 1.5.4+).

Patch by Jan Marc Hoffmann.

src/http/ngx_http_core_module.c

index f8c6956456b5cea1da79fef4cfc7712349a89b8e..d2e29136d0143282434f325a1c386151dbbf8793 100644 (file)
@@ -1144,7 +1144,9 @@ ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
         }
 
         if (rc == NGX_HTTP_FORBIDDEN || rc == NGX_HTTP_UNAUTHORIZED) {
-            r->access_code = rc;
+            if (r->access_code != NGX_HTTP_UNAUTHORIZED) {
+                r->access_code = rc;
+            }
 
             r->phase_handler++;
             return NGX_AGAIN;