mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 02:42:22 +08:00
ContextHandler: unexport cfg (#101396)
This commit is contained in:
@ -29,7 +29,7 @@ import (
|
||||
func ProvideService(cfg *setting.Cfg, authenticator authn.Authenticator, features featuremgmt.FeatureToggles,
|
||||
) *ContextHandler {
|
||||
return &ContextHandler{
|
||||
Cfg: cfg,
|
||||
cfg: cfg,
|
||||
authenticator: authenticator,
|
||||
features: features,
|
||||
}
|
||||
@ -37,7 +37,7 @@ func ProvideService(cfg *setting.Cfg, authenticator authn.Authenticator, feature
|
||||
|
||||
// ContextHandler is a middleware.
|
||||
type ContextHandler struct {
|
||||
Cfg *setting.Cfg
|
||||
cfg *setting.Cfg
|
||||
authenticator authn.Authenticator
|
||||
features featuremgmt.FeatureToggles
|
||||
}
|
||||
@ -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)
|
||||
@ -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))
|
||||
}
|
||||
|
||||
@ -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())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user