aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-03-05 17:25:38 -0500
committerGitHub <[email protected]>2024-03-05 22:25:38 +0000
commit5ed8689629ed88832f015cb507332adde03faabe (patch)
treeeb0540a7071d393c8e65cb873132771f616c3e8a
parent3ae07a73dc057c3a12486b78872c5e1391ec7cc9 (diff)
downloadcaddy-5ed8689629ed88832f015cb507332adde03faabe.tar.gz
caddy-5ed8689629ed88832f015cb507332adde03faabe.zip
vars: Allow overriding `http.auth.user.id` in replacer as a special case (#6108)
-rw-r--r--modules/caddyhttp/vars.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/caddyhttp/vars.go b/modules/caddyhttp/vars.go
index 917a15051..f5afe264a 100644
--- a/modules/caddyhttp/vars.go
+++ b/modules/caddyhttp/vars.go
@@ -57,6 +57,12 @@ func (m VarsMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next H
v = repl.ReplaceAll(valStr, "")
}
vars[keyExpanded] = v
+
+ // Special case: the user ID is in the replacer, pulled from there
+ // for access logs. Allow users to override it with the vars handler.
+ if keyExpanded == "http.auth.user.id" {
+ repl.Set(keyExpanded, v)
+ }
}
return next.ServeHTTP(w, r)
}