xrole

package
v0.0.0-...-d95d571 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CustomerRolePermissionTypePage     = role.RolePermissionTypePage
	CustomerRolePermissionTypeBehavior = role.RolePermissionTypeBehavior
)

Variables

View Source
var Behaviors = perm.NewBehaviors()
View Source
var CustomerRolePermissionType = echo.NewKVData().
	Add(CustomerRolePermissionTypePage, `页面权限`, echo.KVOptX(
		perm.NewHandle().SetTmpl(`official/customer/role/edit_perm_page`).SetTmpl(`official/customer/role/edit_perm_page_foot`, `foot`).
			SetGenerator(PermPageGenerator).
			SetParser(PermPageParser).
			SetChecker(PermPageChecker).
			SetItemLister(PermPageList).
			OnRender(PermPageOnRender),
	)).
	Add(CustomerRolePermissionTypeBehavior, `行为权限`, echo.KVOptX(
		perm.NewHandle().SetTmpl(`official/customer/role/edit_perm_behavior`).SetTmpl(`official/customer/role/edit_perm_behavior_foot`, `foot`).
			SetGenerator(PermBehaviorGenerator).
			SetParser(PermBehaviorParser).
			SetChecker(PermBehaviorChecker).
			SetItemLister(PermBehaviorList).
			OnRender(PermBehaviorOnRender).
			SetIsValid(PermBehaviorIsValid),
	))
View Source
var PermPageList = func(ctx echo.Context) ([]interface{}, error) {
	return nil, nil
}
View Source
var SpecialAuths = AuthCheckers{
	`/user/file/crop`: func(
		c echo.Context,
		rpath string,
		customer *dbschema.OfficialCustomer,
		permission *RolePermission,
	) (err error, ppath string, returning bool) {
		ppath = `/user/file/upload/:type`
		return
	},
}

Functions

func AuthRegister

func AuthRegister(ppath string, checker AuthChecker)

func AuthUnregister

func AuthUnregister(ppath string)

func CheckPermissionByRouteName

func CheckPermissionByRouteName(ctx echo.Context, customer *dbschema.OfficialCustomer, permission *RolePermission, name string) bool

func CheckPermissionByRoutePath

func CheckPermissionByRoutePath(ctx echo.Context, customer *dbschema.OfficialCustomer, permission *RolePermission, routePath string) error
func NavTreeCached() *perm.Map

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 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 RegisterPublic

func RegisterPublic(ppath string)

func UnregisterPublic

func UnregisterPublic(ppath string)

Types

type AuthChecker

type AuthChecker func(
	c echo.Context,
	rpath string,
	customer *dbschema.OfficialCustomer,
	permission *RolePermission,
) (err error, ppath string, returning bool)

type AuthCheckers

type AuthCheckers map[string]AuthChecker

func (AuthCheckers) Check

func (a AuthCheckers) Check(
	c echo.Context,
	rpath string,
	customer *dbschema.OfficialCustomer,
	permission *RolePermission,
) (err error, ppath string, returning bool)

type CustomerRoleWithPermissions

type CustomerRoleWithPermissions struct {
	*dbschema.OfficialCustomerRole
	Permissions []*dbschema.OfficialCustomerRolePermission `db:"-,relation=role_id:id"`
}

func (*CustomerRoleWithPermissions) GetPermissions

func (u *CustomerRoleWithPermissions) GetPermissions() []role.PermissionConfiger

type RolePermission

type RolePermission struct {
	*role.CommonPermission
	Roles []*CustomerRoleWithPermissions
}

func NewRolePermission

func NewRolePermission() *RolePermission

func (*RolePermission) Init

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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