From e5c12421f7ce544e33338e84f08ceff5faf8aba2 Mon Sep 17 00:00:00 2001 From: aoiasd <45024769+aoiasd@users.noreply.github.com> Date: Tue, 18 Mar 2025 18:02:20 +0800 Subject: [PATCH] enhance: remain raw token for audit log (#40637) Signed-off-by: aoiasd --- internal/distributed/proxy/httpserver/constant.go | 1 + internal/distributed/proxy/service.go | 1 + internal/proxy/accesslog/info/restful_info.go | 1 + 3 files changed, 3 insertions(+) diff --git a/internal/distributed/proxy/httpserver/constant.go b/internal/distributed/proxy/httpserver/constant.go index 9cdd98c65a..a8e1a185ad 100644 --- a/internal/distributed/proxy/httpserver/constant.go +++ b/internal/distributed/proxy/httpserver/constant.go @@ -81,6 +81,7 @@ const ( const ( ContextRequest = "request" ContextUsername = "username" + ContextToken = "token" VectorCollectionsPath = "/vector/collections" VectorCollectionsCreatePath = "/vector/collections/create" VectorCollectionsDescribePath = "/vector/collections/describe" diff --git a/internal/distributed/proxy/service.go b/internal/distributed/proxy/service.go index 5b4d16be31..fcf85179d9 100644 --- a/internal/distributed/proxy/service.go +++ b/internal/distributed/proxy/service.go @@ -139,6 +139,7 @@ func authenticate(c *gin.Context) { user, err := proxy.VerifyAPIKey(rawToken) if err == nil { c.Set(httpserver.ContextUsername, user) + c.Set(httpserver.ContextToken, rawToken) return } log.Ctx(context.TODO()).Warn("fail to verify apikey", zap.Error(err)) diff --git a/internal/proxy/accesslog/info/restful_info.go b/internal/proxy/accesslog/info/restful_info.go index 69e7742cdd..8e807e2ecf 100644 --- a/internal/proxy/accesslog/info/restful_info.go +++ b/internal/proxy/accesslog/info/restful_info.go @@ -34,6 +34,7 @@ const ( ContextReturnCode = "code" ContextReturnMessage = "message" ContextRequest = "request" + ContextToken = "token" ) type RestfulInfo struct {