[PATCH] Allow modules to set headers_in.user

Erik Dubbelboer erik at dubbelboer.com
Sun Aug 16 09:29:52 UTC 2015


# HG changeset patch
# User Erik Dubbelboer <erik at dubbelboer.com>
# Date 1439715629 0
# Node ID c6f0f112eb446b7ab4bc69c9e4e594dd79ca3293
# Parent  bd55d75a1410502a9b4ac6fb44ec4528437b530a
Allow modules to set headers_in.user

Requesting $remote_user will always call ngx_http_auth_basic_user
which will always overwrite headers_in.user.
Modules that specify different modes of authentication,
such as Digest, can not set $remote_use without this patch.

diff -r bd55d75a1410 -r c6f0f112eb44 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Sun Aug 16 10:51:34 2015 +0300
+++ b/src/http/ngx_http_core_module.c	Sun Aug 16 09:00:29 2015 +0000
@@ -2049,8 +2049,13 @@
     ngx_str_t   auth, encoded;
     ngx_uint_t  len;
 
-    if (r->headers_in.user.len == 0 && r->headers_in.user.data != NULL) {
-        return NGX_DECLINED;
+    if (r->headers_in.user.data != NULL) {
+        if (r->headers_in.user.len == 0) {
+            return NGX_DECLINED;
+        } else {
+            /* headers_in.user is already set, don't parse again. */
+            return NGX_OK;
+        }
     }
 
     if (r->headers_in.authorization == NULL) {



More information about the nginx-devel mailing list