role

package
v5.3.3-pre4 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: AGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RolePermissionTypePage     = `page`
	RolePermissionTypeCommand  = `command`
	RolePermissionTypeBehavior = `behavior`
)

Variables

View Source
var Behaviors = perm.NewBehaviors()
View Source
var PermCommandList = func(ctx echo.Context) ([]interface{}, error) {
	return nil, nil
}
View Source
var PermPageList = func(ctx echo.Context) ([]interface{}, error) {
	return nil, nil
}
View Source
var SpecialAuths = map[string]AuthChecker{
	`/server/cmdSend/*`: authServerCmdSend,
	`server/dynamic`:    authServerStatus,
	`/server/cmd`:       authCmd,
	`/manager/crop`:     authCrop,
}
View Source
var UserRolePermissionType = echo.NewKVData().
	Add(RolePermissionTypePage, `页面权限`, echo.KVOptX(
		perm.NewHandle().SetTmpl(`/manager/role_edit_perm_page`).SetTmpl(`/manager/role_edit_perm_page_foot`, `foot`).
			SetGenerator(PermPageGenerator).
			SetParser(PermPageParser).
			SetChecker(PermPageChecker).
			SetItemLister(PermPageList).
			OnRender(PermPageOnRender),
	)).
	Add(RolePermissionTypeCommand, `指令集权限`, echo.KVOptX(
		perm.NewHandle().SetTmpl(`/manager/role_edit_perm_command`).
			SetGenerator(PermCommandGenerator).
			SetParser(PermCommandParser).
			SetChecker(PermCommandChecker).
			SetItemLister(PermCommandList).
			OnRender(PermCommandOnRender).
			SetIsValid(PermCommandIsValid),
	)).
	Add(RolePermissionTypeBehavior, `行为权限`, echo.KVOptX(
		perm.NewHandle().SetTmpl(`/manager/role_edit_perm_behavior`).SetTmpl(`/manager/role_edit_perm_behavior_foot`, `foot`).
			SetGenerator(PermBehaviorGenerator).
			SetParser(PermBehaviorParser).
			SetChecker(PermBehaviorChecker).
			SetItemLister(PermBehaviorList).
			OnRender(PermBehaviorOnRender).
			SetIsValid(PermBehaviorIsValid),
	))

Functions

func AuthDependency added in v5.2.5

func AuthDependency(c echo.Context, user *dbschema.NgingUser, permission *RolePermission, route string) error

func AuthRegister

func AuthRegister(ppath string, checker AuthChecker)

func AuthUnregister

func AuthUnregister(ppath string)

func GetDependency added in v5.2.5

func GetDependency(route string) []string

func IsFounder

func IsFounder(user *dbschema.NgingUser) bool

func PermBehaviorChecker

func PermBehaviorChecker(ctx echo.Context, parsed interface{}, current string) (interface{}, error)

func PermBehaviorGenerator

func PermBehaviorGenerator(ctx echo.Context) (string, error)

func PermBehaviorIsValid

func PermBehaviorIsValid(ctx echo.Context) bool

func PermBehaviorList

func PermBehaviorList(ctx echo.Context) ([]interface{}, error)

func PermBehaviorOnRender

func PermBehaviorOnRender(ctx echo.Context) error

func PermBehaviorParser

func PermBehaviorParser(ctx echo.Context, rule string) (interface{}, error)

func PermCommandChecker

func PermCommandChecker(ctx echo.Context, parsed interface{}, current string) (interface{}, error)

func PermCommandGenerator

func PermCommandGenerator(ctx echo.Context) (string, error)

func PermCommandIsValid

func PermCommandIsValid(ctx echo.Context) bool

func PermCommandOnRender

func PermCommandOnRender(ctx echo.Context) error

func PermCommandParser

func PermCommandParser(ctx echo.Context, rule string) (interface{}, error)

func PermPageChecker

func PermPageChecker(ctx echo.Context, parsed interface{}, current string) (interface{}, error)

func PermPageGenerator

func PermPageGenerator(ctx echo.Context) (string, error)

func PermPageOnRender

func PermPageOnRender(ctx echo.Context) error

func PermPageParser

func PermPageParser(ctx echo.Context, rule string) (interface{}, error)

func RegisterAuthDependency added in v5.2.5

func RegisterAuthDependency(route string, dependencyRoutes ...string)

Types

type AuthChecker

type AuthChecker func(
	h echo.Handler,
	c echo.Context,
	user *dbschema.NgingUser,
	permission *RolePermission,
) (ppath string, returning bool, err error)

type Combiner added in v5.2.2

type Combiner interface {
	Combine(interface{}) interface{}
}

type CommonPermission

type CommonPermission struct {
	DefinedType *echo.KVData
	Combined    map[string]string
	// contains filtered or unexported fields
}

func NewCommonPermission

func NewCommonPermission(d *echo.KVData, c navigate.Checker) *CommonPermission

func (*CommonPermission) Check

func (r *CommonPermission) Check(ctx echo.Context, permPath string) bool

func (*CommonPermission) CheckBehavior

func (r *CommonPermission) CheckBehavior(ctx echo.Context, permPath string) *perm.CheckedBehavior

func (*CommonPermission) CheckByType

func (r *CommonPermission) CheckByType(ctx echo.Context, typ string, permPath string) interface{}

func (*CommonPermission) CheckCmd

func (r *CommonPermission) CheckCmd(ctx echo.Context, permPath string) bool

func (*CommonPermission) FilterNavigate

func (r *CommonPermission) FilterNavigate(ctx echo.Context, navList *navigate.List) navigate.List

FilterNavigate 过滤导航菜单,只显示有权限的菜单

func (*CommonPermission) Get

func (r *CommonPermission) Get(ctx echo.Context, typ string) interface{}

func (*CommonPermission) HasNavigate

func (r *CommonPermission) HasNavigate(ctx echo.Context, navList *navigate.List) bool

func (*CommonPermission) Init

type ICheckByType

type ICheckByType interface {
	CheckByType(ctx echo.Context, typ string, permPath string) interface{}
}

type PermissionConfiger

type PermissionConfiger interface {
	GetType() string
	GetPermission() string
}

type PermissionsGetter

type PermissionsGetter interface {
	GetPermissions() []PermissionConfiger
}

type RolePermission

type RolePermission struct {
	*CommonPermission
	Roles []*UserRoleWithPermissions
}

func NewRolePermission

func NewRolePermission() *RolePermission

func (*RolePermission) Init

type UserRoleWithPermissions

type UserRoleWithPermissions struct {
	*dbschema.NgingUserRole
	Permissions []*dbschema.NgingUserRolePermission `db:"-,relation=role_id:id"`
}

func (*UserRoleWithPermissions) GetPermissions

func (u *UserRoleWithPermissions) GetPermissions() []PermissionConfiger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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