Documentation ¶
Index ¶
- Variables
- func InitAccessControlGuardian(cfg *setting.Cfg, ac accesscontrol.AccessControl, ...)
- func MockDashboardGuardian(mock *FakeDashboardGuardian)
- type DashboardGuardian
- func NewAccessControlDashboardGuardian(ctx context.Context, cfg *setting.Cfg, dashboardId int64, ...) (DashboardGuardian, error)
- func NewAccessControlDashboardGuardianByDashboard(ctx context.Context, cfg *setting.Cfg, dashboard *dashboards.Dashboard, ...) (DashboardGuardian, error)
- func NewAccessControlDashboardGuardianByUID(ctx context.Context, cfg *setting.Cfg, dashboardUID string, ...) (DashboardGuardian, error)
- func NewAccessControlFolderGuardian(ctx context.Context, cfg *setting.Cfg, f *folder.Folder, ...) (DashboardGuardian, error)
- type FakeDashboardGuardian
- func (g *FakeDashboardGuardian) CanAdmin() (bool, error)
- func (g *FakeDashboardGuardian) CanCreate(_ int64, _ bool) (bool, error)
- func (g *FakeDashboardGuardian) CanDelete() (bool, error)
- func (g *FakeDashboardGuardian) CanEdit() (bool, error)
- func (g *FakeDashboardGuardian) CanSave() (bool, error)
- func (g *FakeDashboardGuardian) CanView() (bool, error)
- type Provider
Constants ¶
This section is empty.
Variables ¶
var ( ErrGuardianGetDashboardFailure = errutil.Internal("guardian.getDashboardFailure", errutil.WithPublicMessage("Failed to get dashboard")) ErrGuardianDashboardNotFound = errutil.NotFound("guardian.dashboardNotFound") ErrGuardianFolderNotFound = errutil.NotFound("guardian.folderNotFound") )
var New = func(ctx context.Context, dashId int64, orgId int64, user identity.Requester) (DashboardGuardian, error) { panic("no guardian factory implementation provided") }
New factory for creating a new dashboard guardian instance When using access control this function is replaced on startup and the AccessControlDashboardGuardian is returned
var NewByDashboard = func(ctx context.Context, dash *dashboards.Dashboard, orgId int64, user identity.Requester) (DashboardGuardian, error) { panic("no guardian factory implementation provided") }
NewByDashboard factory for creating a new dashboard guardian instance When using access control this function is replaced on startup and the AccessControlDashboardGuardian is returned
var NewByFolder = func(ctx context.Context, f *folder.Folder, orgId int64, user identity.Requester) (DashboardGuardian, error) { panic("no guardian factory implementation provided") }
NewByFolder factory for creating a new folder guardian instance When using access control this function is replaced on startup and the AccessControlDashboardGuardian is returned
var NewByUID = func(ctx context.Context, dashUID string, orgId int64, user identity.Requester) (DashboardGuardian, error) { panic("no guardian factory implementation provided") }
NewByUID factory for creating a new dashboard guardian instance When using access control this function is replaced on startup and the AccessControlDashboardGuardian is returned
Functions ¶
func InitAccessControlGuardian ¶
func InitAccessControlGuardian( cfg *setting.Cfg, ac accesscontrol.AccessControl, dashboardService dashboards.DashboardService, )
Types ¶
type DashboardGuardian ¶
type DashboardGuardian interface { CanSave() (bool, error) CanEdit() (bool, error) CanView() (bool, error) CanAdmin() (bool, error) CanDelete() (bool, error) CanCreate(folderID int64, isFolder bool) (bool, error) }
DashboardGuardian to be used for guard against operations without access on dashboard and acl
func NewAccessControlDashboardGuardian ¶
func NewAccessControlDashboardGuardian( ctx context.Context, cfg *setting.Cfg, dashboardId int64, user identity.Requester, ac accesscontrol.AccessControl, dashboardService dashboards.DashboardService, ) (DashboardGuardian, error)
NewAccessControlDashboardGuardianByDashboard creates a dashboard guardian by the provided dashboardId.
func NewAccessControlDashboardGuardianByDashboard ¶
func NewAccessControlDashboardGuardianByDashboard( ctx context.Context, cfg *setting.Cfg, dashboard *dashboards.Dashboard, user identity.Requester, ac accesscontrol.AccessControl, dashboardService dashboards.DashboardService, ) (DashboardGuardian, error)
NewAccessControlDashboardGuardianByDashboard creates a dashboard guardian by the provided dashboard. This constructor should be preferred over the other two if the dashboard in available since it avoids querying the database for fetching the dashboard.
func NewAccessControlDashboardGuardianByUID ¶
func NewAccessControlDashboardGuardianByUID( ctx context.Context, cfg *setting.Cfg, dashboardUID string, user identity.Requester, ac accesscontrol.AccessControl, dashboardService dashboards.DashboardService, ) (DashboardGuardian, error)
NewAccessControlDashboardGuardianByDashboard creates a dashboard guardian by the provided dashboardUID.
func NewAccessControlFolderGuardian ¶
func NewAccessControlFolderGuardian( ctx context.Context, cfg *setting.Cfg, f *folder.Folder, user identity.Requester, ac accesscontrol.AccessControl, dashboardService dashboards.DashboardService, ) (DashboardGuardian, error)
NewAccessControlFolderGuardian creates a folder guardian by the provided folder.
type FakeDashboardGuardian ¶
type FakeDashboardGuardian struct { DashID int64 DashUID string OrgID int64 User identity.Requester CanSaveValue bool CanEditValue bool CanViewValue bool CanAdminValue bool CanViewUIDs []string CanEditUIDs []string CanSaveUIDs []string }
nolint:unused
func (*FakeDashboardGuardian) CanAdmin ¶
func (g *FakeDashboardGuardian) CanAdmin() (bool, error)
func (*FakeDashboardGuardian) CanCreate ¶
func (g *FakeDashboardGuardian) CanCreate(_ int64, _ bool) (bool, error)
func (*FakeDashboardGuardian) CanDelete ¶
func (g *FakeDashboardGuardian) CanDelete() (bool, error)
func (*FakeDashboardGuardian) CanEdit ¶
func (g *FakeDashboardGuardian) CanEdit() (bool, error)
func (*FakeDashboardGuardian) CanSave ¶
func (g *FakeDashboardGuardian) CanSave() (bool, error)
func (*FakeDashboardGuardian) CanView ¶
func (g *FakeDashboardGuardian) CanView() (bool, error)
type Provider ¶
type Provider struct{}
func ProvideService ¶
func ProvideService( cfg *setting.Cfg, ac accesscontrol.AccessControl, dashboardService dashboards.DashboardService, teamService team.Service, ) *Provider