Plugins: Forward user header (X-Grafana-User) in backend plugin requests (#58646)
Grafana would forward the X-Grafana-User header to backend plugin request when dataproxy.send_user_header is enabled. In addition, X-Grafana-User will be automatically forwarded in outgoing HTTP requests for core/builtin HTTP datasources. Use grafana-plugin-sdk-go v0.147.0. Fixes #47734 Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ecf83a6df9
commit
6478d0a5ef
@@ -9,7 +9,6 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
// interpolateString accepts template data and return a string with substitutions
|
||||
@@ -84,11 +83,3 @@ func setBodyContent(req *http.Request, route *plugins.Route, data templateData)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Set the X-Grafana-User header if needed (and remove if not)
|
||||
func applyUserHeader(sendUserHeader bool, req *http.Request, user *user.SignedInUser) {
|
||||
req.Header.Del("X-Grafana-User")
|
||||
if sendUserHeader && !user.IsAnonymous {
|
||||
req.Header.Set("X-Grafana-User", user.Login)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user