diff --git a/server/channels/app/plugin.go b/server/channels/app/plugin.go index a2f826b4c1..6b4c55a52e 100644 --- a/server/channels/app/plugin.go +++ b/server/channels/app/plugin.go @@ -964,6 +964,8 @@ func (ch *Channels) processPrepackagedPlugins(prepackagedPluginsDir string) erro return nil } +var SemVerV2 = semver.MustParse("2.0.0") + // processPrepackagedPlugin will return the prepackaged plugin metadata and will also // install the prepackaged plugin if it had been previously enabled and AutomaticPrepackagedPlugins is true. func (ch *Channels) processPrepackagedPlugin(pluginPath *pluginSignaturePath) (*plugin.PrepackagedPlugin, error) { @@ -990,6 +992,21 @@ func (ch *Channels) processPrepackagedPlugin(pluginPath *pluginSignaturePath) (* logger = logger.With(mlog.String("plugin_id", plugin.Manifest.Id)) + if plugin.Manifest.Id == model.PluginIdPlaybooks { + version, err := semver.Parse(plugin.Manifest.Version) + if err != nil { + return nil, errors.Wrapf(err, "Unable to verify prepackaged playbooks version") + } + if version.GTE(SemVerV2) { + license := ch.License() + canUsePlaybookv2 := license != nil && license.IsE20OrEnterprise() + if !canUsePlaybookv2 { + logger.Info("Skip installing prepackaged playbooks because the license does not allow it") + return plugin, nil + } + } + } + // Skip installing the plugin at all if automatic prepackaged plugins is disabled if !*ch.cfgSvc.Config().PluginSettings.AutomaticPrepackagedPlugins { logger.Info("Not installing prepackaged plugin: automatic prepackaged plugins disabled") diff --git a/server/public/model/license.go b/server/public/model/license.go index b1625fd01a..13f575b21f 100644 --- a/server/public/model/license.go +++ b/server/public/model/license.go @@ -385,6 +385,11 @@ func (l *License) HasSharedChannels() bool { l.SkuShortName == LicenseShortSkuEnterprise } +// IsE20OrEnterprise returns true when the license is for E20 or Enterprise. +func (l *License) IsE20OrEnterprise() bool { + return l.SkuShortName == LicenseShortSkuE20 || l.SkuShortName == LicenseShortSkuEnterprise +} + // NewTestLicense returns a license that expires in the future and has the given features. func NewTestLicense(features ...string) *License { ret := &License{