From ac2f7dedaad9b5e9bfd0e41fd4480f0e0526ec84 Mon Sep 17 00:00:00 2001 From: rinfx Date: Thu, 9 Oct 2025 11:22:09 +0800 Subject: [PATCH] [key-auth] record consumer name once the consumer name is determined (#2978) --- plugins/wasm-go/extensions/key-auth/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/wasm-go/extensions/key-auth/main.go b/plugins/wasm-go/extensions/key-auth/main.go index 844ee72ca..6d9aa33f3 100644 --- a/plugins/wasm-go/extensions/key-auth/main.go +++ b/plugins/wasm-go/extensions/key-auth/main.go @@ -291,6 +291,8 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log log return deniedUnauthorizedConsumer() } + proxywasm.AddHttpRequestHeader("X-Mse-Consumer", name) + // 全局生效: // - global_auth == true 且 当前 domain/route 未配置该插件 // - global_auth 未设置 且 没有任何一个 domain/route 配置该插件 @@ -343,7 +345,6 @@ func deniedUnauthorizedConsumer() types.Action { } func authenticated(name string) types.Action { - _ = proxywasm.AddHttpRequestHeader("X-Mse-Consumer", name) return types.ActionContinue }