Chore: Use Grafana API to retrieve the public key to validate plugins (#66439)

This commit is contained in:
Andres Martinez Gotor
2023-04-18 16:12:05 +02:00
committed by GitHub
parent f612a72f96
commit 98c695c68f
18 changed files with 487 additions and 103 deletions
@@ -5,10 +5,11 @@ import (
"strings"
pCfg "github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/setting"
)
func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg) (*pCfg.Cfg, error) {
func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg, features *featuremgmt.FeatureManager) (*pCfg.Cfg, error) {
plugins := settingProvider.Section("plugins")
allowedUnsigned := grafanaCfg.PluginsAllowUnsigned
if len(plugins.KeyValue("allow_loading_unsigned_plugins").Value()) > 0 {
@@ -25,6 +26,7 @@ func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg) (*
if err != nil {
return nil, fmt.Errorf("new opentelemetry cfg: %w", err)
}
return pCfg.NewCfg(
settingProvider.KeyValue("", "app_mode").MustBool(grafanaCfg.Env == setting.Dev),
grafanaCfg.PluginsPath,
@@ -38,6 +40,7 @@ func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg) (*
grafanaCfg.PluginLogBackendRequests,
grafanaCfg.PluginsCDNURLTemplate,
tracingCfg,
featuremgmt.ProvideToggles(features),
), nil
}
@@ -66,6 +66,8 @@ var WireSet = wire.NewSet(
wire.Bind(new(pluginsettings.Service), new(*pluginSettings.Service)),
filestore.ProvideService,
wire.Bind(new(plugins.FileStore), new(*filestore.Service)),
wire.Bind(new(plugins.SignatureCalculator), new(*signature.Signature)),
signature.ProvideService,
)
// WireExtensionSet provides a wire.ProviderSet of plugin providers that can be