mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Access control: Move licensing actions to licensing package (#46588)
* Move licensing actions to licensing package
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/models"
|
"github.com/grafana/grafana/pkg/models"
|
||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"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/setting"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
@@ -246,7 +247,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
|
|||||||
"licenseInfo": map[string]interface{}{
|
"licenseInfo": map[string]interface{}{
|
||||||
"expiry": hs.License.Expiry(),
|
"expiry": hs.License.Expiry(),
|
||||||
"stateInfo": hs.License.StateInfo(),
|
"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(),
|
"edition": hs.License.Edition(),
|
||||||
"enabledFeatures": hs.License.EnabledFeatures(),
|
"enabledFeatures": hs.License.EnabledFeatures(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -310,12 +310,6 @@ const (
|
|||||||
// Settings scope
|
// Settings scope
|
||||||
ScopeSettingsAll = "settings:*"
|
ScopeSettingsAll = "settings:*"
|
||||||
|
|
||||||
// Licensing related actions
|
|
||||||
ActionLicensingRead = "licensing:read"
|
|
||||||
ActionLicensingUpdate = "licensing:update"
|
|
||||||
ActionLicensingDelete = "licensing:delete"
|
|
||||||
ActionLicensingReportsRead = "licensing.reports:read"
|
|
||||||
|
|
||||||
// Team related actions
|
// Team related actions
|
||||||
ActionTeamsCreate = "teams:create"
|
ActionTeamsCreate = "teams:create"
|
||||||
ActionTeamsDelete = "teams:delete"
|
ActionTeamsDelete = "teams:delete"
|
||||||
@@ -387,9 +381,3 @@ var (
|
|||||||
const RoleGrafanaAdmin = "Grafana Admin"
|
const RoleGrafanaAdmin = "Grafana Admin"
|
||||||
|
|
||||||
const FixedRolePrefix = "fixed:"
|
const FixedRolePrefix = "fixed:"
|
||||||
|
|
||||||
// LicensingPageReaderAccess defines permissions that grant access to the licensing and stats page
|
|
||||||
var LicensingPageReaderAccess = EvalAny(
|
|
||||||
EvalPermission(ActionLicensingRead),
|
|
||||||
EvalPermission(ActionServerStatsRead),
|
|
||||||
)
|
|
||||||
|
|||||||
16
pkg/services/licensing/accesscontrol.go
Normal file
16
pkg/services/licensing/accesscontrol.go
Normal file
@@ -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),
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user