mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 10:32:42 +08:00
IDForwarding: Always forward id tokens to plugins (#81041)
* Always forward id tokens to plugins
This commit is contained in:
@ -5,11 +5,8 @@ import (
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
"github.com/grafana/grafana/pkg/services/contexthandler"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
const forwardIDHeaderName = "X-Grafana-Id"
|
||||
@ -36,15 +33,6 @@ func (m *ForwardIDMiddleware) applyToken(ctx context.Context, pCtx backend.Plugi
|
||||
return nil
|
||||
}
|
||||
|
||||
jsonDataBytes, err := simplejson.NewJson(pCtx.DataSourceInstanceSettings.JSONData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !auth.IsIDForwardingEnabledForDataSource(&datasources.DataSource{JsonData: jsonDataBytes}) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// token will only be present if faeturemgmt.FlagIdForwarding is enabled
|
||||
if token := reqCtx.SignedInUser.GetIDToken(); token != "" {
|
||||
req.SetHTTPHeader(forwardIDHeaderName, token)
|
||||
|
Reference in New Issue
Block a user