Skip to content

Commit

Permalink
ContextHandler: unexport cfg (grafana#101396)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalleep authored Feb 27, 2025
1 parent 743991e commit c6a7897
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/services/contexthandler/contexthandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import (
func ProvideService(cfg *setting.Cfg, authenticator authn.Authenticator, features featuremgmt.FeatureToggles,
) *ContextHandler {
return &ContextHandler{
Cfg: cfg,
cfg: cfg,
authenticator: authenticator,
features: features,
}
}

// ContextHandler is a middleware.
type ContextHandler struct {
Cfg *setting.Cfg
cfg *setting.Cfg
authenticator authn.Authenticator
features featuremgmt.FeatureToggles
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (h *ContextHandler) Middleware(next http.Handler) http.Handler {
// inject ReqContext in the context
ctx = context.WithValue(ctx, reqContextKey{}, reqContext)
// store list of possible auth header in context
ctx = WithAuthHTTPHeaders(ctx, h.Cfg)
ctx = WithAuthHTTPHeaders(ctx, h.cfg)
// Set the context for the http.Request.Context
// This modifies both r and reqContext.Req since they point to the same value
*reqContext.Req = *reqContext.Req.WithContext(ctx)
Expand Down Expand Up @@ -137,7 +137,7 @@ func (h *ContextHandler) Middleware(next http.Handler) http.Handler {
attribute.Int64("userId", reqContext.UserID),
))

if h.Cfg.IDResponseHeaderEnabled && reqContext.SignedInUser != nil {
if h.cfg.IDResponseHeaderEnabled && reqContext.SignedInUser != nil {
reqContext.Resp.Before(h.addIDHeaderEndOfRequestFunc(reqContext.SignedInUser))
}

Expand Down Expand Up @@ -167,11 +167,11 @@ func (h *ContextHandler) addIDHeaderEndOfRequestFunc(ident identity.Requester) w
return
}

if _, ok := h.Cfg.IDResponseHeaderNamespaces[string(ident.GetIdentityType())]; !ok {
if _, ok := h.cfg.IDResponseHeaderNamespaces[string(ident.GetIdentityType())]; !ok {
return
}

headerName := fmt.Sprintf("%s-Identity-Id", h.Cfg.IDResponseHeaderPrefix)
headerName := fmt.Sprintf("%s-Identity-Id", h.cfg.IDResponseHeaderPrefix)
w.Header().Add(headerName, ident.GetID())
}
}
Expand Down

0 comments on commit c6a7897

Please sign in to comment.