vars: Allow overriding `http.auth.user.id` in replacer as a special case (#6108)

This commit is contained in:
Francis Lavoie 2024-03-05 17:25:38 -05:00 committed by GitHub
parent 3ae07a73dc
commit 5ed8689629
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -57,6 +57,12 @@ func (m VarsMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next H
v = repl.ReplaceAll(valStr, "") v = repl.ReplaceAll(valStr, "")
} }
vars[keyExpanded] = v 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) return next.ServeHTTP(w, r)
} }