perm

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: AGPL-3.0 Imports: 3 Imported by: 0

README

权限验证

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SpecialAuths = map[string]AuthChecker{
	`/server/cmdSend/*`: func(
		h echo.Handler,
		c echo.Context,
		rpath string,
		user *dbschema.User,
		roleM *model.UserRole,
		roleList []*dbschema.UserRole,
	) (err error, ppath string, returning bool) {
		returning = true
		c.SetFunc(`CheckPerm`, func(id string) error {
			if user.Id == 1 {
				return nil
			}
			if len(id) > 0 {
				if !roleM.CheckCmdPerm2(roleList, id) {
					return echo.ErrForbidden
				}
			} else {
				if !roleM.CheckPerm2(roleList, `server/cmd`) {
					return echo.ErrForbidden
				}
			}
			return nil
		})
		err = h.Handle(c)
		return
	},
	`server/dynamic`: func(
		h echo.Handler,
		c echo.Context,
		rpath string,
		user *dbschema.User,
		roleM *model.UserRole,
		roleList []*dbschema.UserRole,
	) (err error, ppath string, returning bool) {
		ppath = `server/sysinfo`
		return
	},
	`/server/cmd`: func(
		h echo.Handler,
		c echo.Context,
		rpath string,
		user *dbschema.User,
		roleM *model.UserRole,
		roleList []*dbschema.UserRole,
	) (err error, ppath string, returning bool) {
		id := c.Form(`id`)
		if len(id) > 0 {
			returning = true
			if !roleM.CheckCmdPerm2(roleList, id) {
				err = echo.ErrForbidden
				return
			}
			err = h.Handle(c)
			return
		}
		ppath = `cmd`
		return
	},
	`/manager/crop`: func(
		h echo.Handler,
		c echo.Context,
		rpath string,
		user *dbschema.User,
		roleM *model.UserRole,
		roleList []*dbschema.UserRole,
	) (err error, ppath string, returning bool) {
		ppath = `/manager/upload/:type`
		return
	},
}

Functions

func AuthRegister

func AuthRegister(ppath string, checker AuthChecker)

func AuthUnregister

func AuthUnregister(ppath string)

Types

type AuthChecker

type AuthChecker func(
	h echo.Handler,
	c echo.Context,
	rpath string,
	user *dbschema.User,
	roleM *model.UserRole,
	roleList []*dbschema.UserRole,
) (err error, ppath string, returning bool)

Jump to

Keyboard shortcuts

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