policy

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(policy Policier, action Action, c Context, params []gin.Param)

Types

type Action

type Action byte
const (
	ActionCreate Action = iota
	ActionUpdate
	ActionDelete
	ActionForceDelete
	ActionView
	ActionRestore
)

type Authorization

type Authorization struct {
	auth.RequestUser
}

func (*Authorization) Authorize

func (a *Authorization) Authorize(c Context, policies Policier, action Action) (permit bool, user auth.IUser)

type Policier

type Policier interface {
	Before(IUser auth.IUser, routeParamMap map[key]value) *bool
	Create(IUser auth.IUser, routeParamMap map[key]value) bool
	Update(IUser auth.IUser, routeParamMap map[key]value) bool
	Delete(IUser auth.IUser, routeParamMap map[key]value) bool
	ForceDelete(IUser auth.IUser, routeParamMap map[key]value) bool
	View(IUser auth.IUser, routeParamMap map[key]value) bool
	Restore(IUser auth.IUser, routeParamMap map[key]value) bool
}

type RoutePolicier

type RoutePolicier interface {
	Can(policy Policier, action Action)
}

type UserNotPermitError

type UserNotPermitError struct{}

func (UserNotPermitError) Error

func (e UserNotPermitError) Error() string

Jump to

Keyboard shortcuts

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