diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index 90660bb8797..d86cc36a0c1 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -7,6 +7,7 @@ import ( "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/plugins" "github.com/grafana/grafana/pkg/services/accesscontrol" + "github.com/grafana/grafana/pkg/services/licensing" "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/tsdb/grafanads" "github.com/grafana/grafana/pkg/util" @@ -246,7 +247,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i "licenseInfo": map[string]interface{}{ "expiry": hs.License.Expiry(), "stateInfo": hs.License.StateInfo(), - "licenseUrl": hs.License.LicenseURL(hasAccess(accesscontrol.ReqGrafanaAdmin, accesscontrol.LicensingPageReaderAccess)), + "licenseUrl": hs.License.LicenseURL(hasAccess(accesscontrol.ReqGrafanaAdmin, licensing.PageAccess)), "edition": hs.License.Edition(), "enabledFeatures": hs.License.EnabledFeatures(), }, diff --git a/pkg/services/accesscontrol/models.go b/pkg/services/accesscontrol/models.go index c3fd9f99a7e..be0cdcc469e 100644 --- a/pkg/services/accesscontrol/models.go +++ b/pkg/services/accesscontrol/models.go @@ -310,12 +310,6 @@ const ( // Settings scope ScopeSettingsAll = "settings:*" - // Licensing related actions - ActionLicensingRead = "licensing:read" - ActionLicensingUpdate = "licensing:update" - ActionLicensingDelete = "licensing:delete" - ActionLicensingReportsRead = "licensing.reports:read" - // Team related actions ActionTeamsCreate = "teams:create" ActionTeamsDelete = "teams:delete" @@ -387,9 +381,3 @@ var ( const RoleGrafanaAdmin = "Grafana Admin" const FixedRolePrefix = "fixed:" - -// LicensingPageReaderAccess defines permissions that grant access to the licensing and stats page -var LicensingPageReaderAccess = EvalAny( - EvalPermission(ActionLicensingRead), - EvalPermission(ActionServerStatsRead), -) diff --git a/pkg/services/licensing/accesscontrol.go b/pkg/services/licensing/accesscontrol.go new file mode 100644 index 00000000000..f5a0f1e6331 --- /dev/null +++ b/pkg/services/licensing/accesscontrol.go @@ -0,0 +1,16 @@ +package licensing + +import "github.com/grafana/grafana/pkg/services/accesscontrol" + +const ( + ActionRead = "licensing:read" + ActionUpdate = "licensing:update" + ActionDelete = "licensing:delete" + ActionReportsRead = "licensing.reports:read" +) + +// PageAccess defines permissions that grant access to the licensing and stats page +var PageAccess = accesscontrol.EvalAny( + accesscontrol.EvalPermission(ActionRead), + accesscontrol.EvalPermission(accesscontrol.ActionServerStatsRead), +)