mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 11:20:27 -06:00
6dbe3b555f
Adding support for backend plugin client middlewares. This allows headers in outgoing backend plugin and HTTP requests to be modified using client middlewares. The following client middlewares added: Forward cookies: Will forward incoming HTTP request Cookies to outgoing plugins.Client and HTTP requests if the datasource has enabled forwarding of cookies (keepCookies). Forward OAuth token: Will set OAuth token headers on outgoing plugins.Client and HTTP requests if the datasource has enabled Forward OAuth Identity (oauthPassThru). Clear auth headers: Will clear any outgoing HTTP headers that was part of the incoming HTTP request and used when authenticating to Grafana. The current suggested way to register client middlewares is to have a separate package, pluginsintegration, responsible for bootstrap/instantiate the backend plugin client with middlewares and/or longer term bootstrap/instantiate plugin management. Fixes #54135 Related to #47734 Related to #57870 Related to #41623 Related to #57065
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
|
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
|
"github.com/grafana/grafana/pkg/services/grpcserver"
|
|
"github.com/grafana/grafana/pkg/services/notifications"
|
|
"github.com/grafana/grafana/pkg/services/oauthtoken/oauthtokentest"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
|
)
|
|
|
|
func ProvideTestEnv(
|
|
server *Server,
|
|
store *sqlstore.SQLStore,
|
|
ns *notifications.NotificationServiceMock,
|
|
grpcServer grpcserver.Provider,
|
|
pluginRegistry registry.Service,
|
|
httpClientProvider httpclient.Provider,
|
|
oAuthTokenService *oauthtokentest.Service,
|
|
) (*TestEnv, error) {
|
|
return &TestEnv{
|
|
server,
|
|
store,
|
|
ns,
|
|
grpcServer,
|
|
pluginRegistry,
|
|
httpClientProvider,
|
|
oAuthTokenService,
|
|
}, nil
|
|
}
|
|
|
|
type TestEnv struct {
|
|
Server *Server
|
|
SQLStore *sqlstore.SQLStore
|
|
NotificationService *notifications.NotificationServiceMock
|
|
GRPCServer grpcserver.Provider
|
|
PluginRegistry registry.Service
|
|
HTTPClientProvider httpclient.Provider
|
|
OAuthTokenService *oauthtokentest.Service
|
|
}
|