Files
Will Browne 5edd96ae77 Plugins: Refactor plugin config into separate env var and request scoped services (#83261)
* seperate services for env + req

* merge with main

* fix tests

* undo changes to golden file

* fix linter

* remove unused fields

* split out new config struct

* provide config

* undo go mod changes

* more renaming

* fix tests

* undo bra.toml changes

* update go.work.sum

* undo changes

* trigger

* apply PR feedback
2024-02-27 12:38:02 +01:00

39 lines
755 B
Go

package signature
import (
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/config"
)
func ProvideOSSAuthorizer(cfg *config.PluginManagementCfg) *UnsignedPluginAuthorizer {
return NewUnsignedAuthorizer(cfg)
}
func NewUnsignedAuthorizer(cfg *config.PluginManagementCfg) *UnsignedPluginAuthorizer {
return &UnsignedPluginAuthorizer{
cfg: cfg,
}
}
type UnsignedPluginAuthorizer struct {
cfg *config.PluginManagementCfg
}
func (u *UnsignedPluginAuthorizer) CanLoadPlugin(p *plugins.Plugin) bool {
if p.Signature != plugins.SignatureStatusUnsigned {
return true
}
if u.cfg.DevMode {
return true
}
for _, pID := range u.cfg.PluginsAllowUnsigned {
if pID == p.ID {
return true
}
}
return false
}