rbac

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Unlicense Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermPermissionCreate  = "rbac.permission.create"
	PermPermissionDelete  = "rbac.permission.delete"
	PermPermissionListAll = "rbac.permission.list"

	PermRoleCreate   = "rbac.role.create"
	PermRoleDelete   = "rbac.role.delete"
	PermRoleListAll  = "rbac.role.list"
	PermRoleAddPerm  = "rbac.role.add_perm"
	PermRoleDelPerm  = "rbac.role.del_perm"
	PermRoleAddBased = "rbac.role.add_based"
	PermRoleDelBased = "rbac.role.del_based"

	PermRbacLogin  = "rbac.login"
	PermGrantRole  = "rbac.grant_role"
	PermCancelRole = "rbac.cancel_role"
)

Variables

View Source
var ErrPermissionDenied = errors.New("sha.rbac: permission denied")
View Source
var ErrUnknownPermission = errors.New("sha.rbac: unknown permission")
View Source
var ErrUnknownRole = errors.New("sha.rbac: unexpected role")

Functions

func GrantRoot

func GrantRoot(rootId int64, rootInfo interface{})

func Init

func Init(router Router, adapter CtxAdapter, options *Options)

func IsGrantedAll

func IsGrantedAll(ctx context.Context, permissions ...string) error

func IsGrantedAny

func IsGrantedAny(ctx context.Context, permissions ...string) error

func Load

func Load(ctx context.Context)

func MustGrantedAll

func MustGrantedAll(ctx context.Context, permissions ...string)

func MustGrantedAny

func MustGrantedAny(ctx context.Context, permissions ...string)

func Recover

func Recover(ctx context.Context)

Types

type CtxAdapter added in v0.0.5

type CtxAdapter interface {
	ValidateForm(ctx context.Context, dist interface{}) error
	SetResponseStatus(ctx context.Context, v int)
	Write(ctx context.Context, p []byte) (int, error)
	WriteJSON(ctx context.Context, v interface{})
	SetError(ctx context.Context, v interface{})
}

type HandlerFunc

type HandlerFunc func(ctx context.Context)

type Options

type Options struct {
	TableNamePrefix  string
	Logger           *log.Logger
	LogReadOperation bool
}

type Router

type Router interface {
	HTTP(method string, path string, handler HandlerFunc, doc validator.Document)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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