Documentation ¶
Index ¶
- Variables
- func AuthRegister(ppath string, checker AuthChecker)
- func AuthUnregister(ppath string)
- type AuthChecker
- type RolePermission
- func (r *RolePermission) Check(permPath string) bool
- func (r *RolePermission) CheckBehavior(permPath string) *perm.CheckedBehavior
- func (r *RolePermission) CheckCmd(permPath string) bool
- func (r *RolePermission) FilterNavigate(navList *navigate.List) navigate.List
- func (r *RolePermission) Init(roleList []*dbschema.NgingUserRole) *RolePermission
Constants ¶
This section is empty.
Variables ¶
View Source
var Behaviors = perm.NewBehaviors()
View Source
var SpecialAuths = map[string]AuthChecker{ `/server/cmdSend/*`: func( h echo.Handler, c echo.Context, user *dbschema.NgingUser, permission *RolePermission, ) (ppath string, returning bool, err error) { returning = true c.SetFunc(`CheckPerm`, func(id string) error { if user.Id == 1 { return nil } if permission == nil { return common.ErrUserNoPerm } if len(id) > 0 { if !permission.CheckCmd(id) { return common.ErrUserNoPerm } } else { if !permission.Check(`server/cmd`) { return common.ErrUserNoPerm } } return nil }) err = h.Handle(c) return }, `server/dynamic`: func( h echo.Handler, c echo.Context, user *dbschema.NgingUser, permission *RolePermission, ) (ppath string, returning bool, err error) { ppath = `server/sysinfo` return }, `/server/cmd`: func( h echo.Handler, c echo.Context, user *dbschema.NgingUser, permission *RolePermission, ) (ppath string, returning bool, err error) { id := c.Form(`id`) if len(id) > 0 { returning = true if permission == nil { err = common.ErrUserNoPerm return } if !permission.CheckCmd(id) { err = common.ErrUserNoPerm return } err = h.Handle(c) return } ppath = `cmd` return }, `/manager/crop`: func( h echo.Handler, c echo.Context, user *dbschema.NgingUser, permission *RolePermission, ) (ppath string, returning bool, err error) { ppath = `/manager/upload/:type` return }, }
Functions ¶
func AuthRegister ¶
func AuthRegister(ppath string, checker AuthChecker)
func AuthUnregister ¶
func AuthUnregister(ppath string)
Types ¶
type AuthChecker ¶
type RolePermission ¶
type RolePermission struct { Actions string Commands string Behaviors string Roles []*dbschema.NgingUserRole // contains filtered or unexported fields }
func New ¶
func New() *RolePermission
func (*RolePermission) Check ¶
func (r *RolePermission) Check(permPath string) bool
func (*RolePermission) CheckBehavior ¶
func (r *RolePermission) CheckBehavior(permPath string) *perm.CheckedBehavior
func (*RolePermission) CheckCmd ¶
func (r *RolePermission) CheckCmd(permPath string) bool
func (*RolePermission) FilterNavigate ¶
func (r *RolePermission) FilterNavigate(navList *navigate.List) navigate.List
FilterNavigate 过滤导航菜单,只显示有权限的菜单
func (*RolePermission) Init ¶
func (r *RolePermission) Init(roleList []*dbschema.NgingUserRole) *RolePermission
Click to show internal directories.
Click to hide internal directories.