guardian

package
v0.0.85-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2023 License: AGPL-3.0 Imports: 9 Imported by: 200

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGuardianPermissionExists = errors.New("permission already exists")
	ErrGuardianOverride         = errors.New("you can only override a permission to be higher")
)
View Source
var New = func(ctx context.Context, dashId int64, orgId int64, user *models.SignedInUser) DashboardGuardian {
	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

Functions

func InitAcessControlGuardian

func InitAcessControlGuardian(store sqlstore.Store, ac accesscontrol.AccessControl, permissionsServices accesscontrol.PermissionsServices)

func InitLegacyGuardian

func InitLegacyGuardian(store sqlstore.Store)

func MockDashboardGuardian

func MockDashboardGuardian(mock *FakeDashboardGuardian)

nolint:unused

Types

type AccessControlDashboardGuardian

type AccessControlDashboardGuardian struct {
	// contains filtered or unexported fields
}

func NewAccessControlDashboardGuardian

func NewAccessControlDashboardGuardian(
	ctx context.Context, dashboardId int64, user *models.SignedInUser,
	store sqlstore.Store, ac accesscontrol.AccessControl, permissionsServices accesscontrol.PermissionsServices,
) *AccessControlDashboardGuardian

func (*AccessControlDashboardGuardian) CanAdmin

func (a *AccessControlDashboardGuardian) CanAdmin() (bool, error)

func (*AccessControlDashboardGuardian) CanCreate

func (a *AccessControlDashboardGuardian) CanCreate(folderID int64, isFolder bool) (bool, error)

func (*AccessControlDashboardGuardian) CanDelete

func (a *AccessControlDashboardGuardian) CanDelete() (bool, error)

func (*AccessControlDashboardGuardian) CanEdit

func (a *AccessControlDashboardGuardian) CanEdit() (bool, error)

func (*AccessControlDashboardGuardian) CanSave

func (a *AccessControlDashboardGuardian) CanSave() (bool, error)

func (*AccessControlDashboardGuardian) CanView

func (a *AccessControlDashboardGuardian) CanView() (bool, error)

func (*AccessControlDashboardGuardian) CheckPermissionBeforeUpdate

func (a *AccessControlDashboardGuardian) CheckPermissionBeforeUpdate(permission models.PermissionType, updatePermissions []*models.DashboardAcl) (bool, error)

func (*AccessControlDashboardGuardian) GetACLWithoutDuplicates

func (a *AccessControlDashboardGuardian) GetACLWithoutDuplicates() ([]*models.DashboardAclInfoDTO, error)

func (*AccessControlDashboardGuardian) GetAcl

GetAcl translate access control permissions to dashboard acl info

func (*AccessControlDashboardGuardian) GetHiddenACL

func (a *AccessControlDashboardGuardian) GetHiddenACL(cfg *setting.Cfg) ([]*models.DashboardAcl, error)

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)
	CheckPermissionBeforeUpdate(permission models.PermissionType, updatePermissions []*models.DashboardAcl) (bool, error)

	// GetAcl returns ACL.
	GetAcl() ([]*models.DashboardAclInfoDTO, error)

	// GetACLWithoutDuplicates returns ACL and strips any permission
	// that already has an inherited permission with higher or equal
	// permission.
	GetACLWithoutDuplicates() ([]*models.DashboardAclInfoDTO, error)
	GetHiddenACL(*setting.Cfg) ([]*models.DashboardAcl, error)
}

DashboardGuardian to be used for guard against operations without access on dashboard and acl

type FakeDashboardGuardian

type FakeDashboardGuardian struct {
	DashId                           int64
	OrgId                            int64
	User                             *models.SignedInUser
	CanSaveValue                     bool
	CanEditValue                     bool
	CanViewValue                     bool
	CanAdminValue                    bool
	HasPermissionValue               bool
	CheckPermissionBeforeUpdateValue bool
	CheckPermissionBeforeUpdateError error
	GetAclValue                      []*models.DashboardAclInfoDTO
	GetHiddenAclValue                []*models.DashboardAcl
}

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)

func (*FakeDashboardGuardian) CheckPermissionBeforeUpdate

func (g *FakeDashboardGuardian) CheckPermissionBeforeUpdate(permission models.PermissionType, updatePermissions []*models.DashboardAcl) (bool, error)

func (*FakeDashboardGuardian) GetACLWithoutDuplicates

func (g *FakeDashboardGuardian) GetACLWithoutDuplicates() ([]*models.DashboardAclInfoDTO, error)

func (*FakeDashboardGuardian) GetAcl

func (*FakeDashboardGuardian) GetHiddenACL

func (g *FakeDashboardGuardian) GetHiddenACL(cfg *setting.Cfg) ([]*models.DashboardAcl, error)

func (*FakeDashboardGuardian) HasPermission

func (g *FakeDashboardGuardian) HasPermission(permission models.PermissionType) (bool, error)

type Provider

type Provider struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL