From 24d1ce0b84681cec502fba3ea3ed27e15f6044b7 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Tue, 13 Feb 2024 17:13:23 -0500 Subject: [PATCH] fix: use struct as key for context Signed-off-by: dovholuknf <46322585+dovholuknf@users.noreply.github.com> --- bootstrap/handlers/auth_middleware.go | 2 +- bootstrap/handlers/httpserver.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bootstrap/handlers/auth_middleware.go b/bootstrap/handlers/auth_middleware.go index 099d8e63..30ace26d 100644 --- a/bootstrap/handlers/auth_middleware.go +++ b/bootstrap/handlers/auth_middleware.go @@ -57,7 +57,7 @@ func VaultAuthenticationHandlerFunc(secretProvider interfaces.SecretProviderExt, lc.Debugf("Authorizing incoming call to '%s' via JWT (Authorization len=%d)", r.URL.Path, len(authHeader)) if secretProvider.IsZeroTrustEnabled() { - zitiCtx := r.Context().Value("zero.trust.identityName") + zitiCtx := r.Context().Value(OpenZitiIdentityKey{}) if zitiCtx != nil { zitiEdgeConn := zitiCtx.(edge.Conn) diff --git a/bootstrap/handlers/httpserver.go b/bootstrap/handlers/httpserver.go index 89b09e97..3c220ad2 100644 --- a/bootstrap/handlers/httpserver.go +++ b/bootstrap/handlers/httpserver.go @@ -54,6 +54,7 @@ type HttpServer struct { type ZitiContext struct { c *ziti.Context } +type OpenZitiIdentityKey struct{} // NewHttpServer is a factory method that returns an initialized HttpServer receiver struct. func NewHttpServer(router *echo.Echo, doListenAndServe bool) *HttpServer { @@ -282,7 +283,7 @@ func RequestLimitMiddleware(sizeLimit int64, lc logger.LoggingClient) echo.Middl func mutator(srcCtx context.Context, c net.Conn) context.Context { if zitiConn, ok := c.(edge.Conn); ok { - return context.WithValue(srcCtx, "zero.trust.identityName", zitiConn) + return context.WithValue(srcCtx, OpenZitiIdentityKey{}, zitiConn) } return srcCtx }