Skip to content

Commit

Permalink
fix: use struct as key for context
Browse files Browse the repository at this point in the history
Signed-off-by: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
  • Loading branch information
dovholuknf committed Feb 26, 2024
1 parent b73cfcd commit 24d1ce0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bootstrap/handlers/auth_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion bootstrap/handlers/httpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

0 comments on commit 24d1ce0

Please sign in to comment.