authz

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Apps = Obj{
		Name: "apps",
		Acts: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodPut,
		},
		AppName: envs.AppNameAdmin(),
	}
	Staffs = Obj{
		Name: "staffs",
		Acts: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodPut,
		},
		AppName: envs.AppNameAdmin(),
	}
	Tokens = Obj{
		Name: "tokens",
		Acts: []string{
			http.MethodGet,
			http.MethodDelete,
		},
		AppName: envs.AppNameAdmin(),
	}
	Groups = Obj{
		Name:     "groups",
		NeedRoot: true,
		Acts: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodPut,
		},
		AppName: envs.AppNameAdmin(),
	}
	Groupships = Obj{
		Name:     "groupships",
		NeedRoot: true,
		Acts: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodDelete,
		},
		AppName: envs.AppNameAdmin(),
	}
	Permissons = Obj{
		Name:     "permissions",
		NeedRoot: true,
		Acts: []string{
			http.MethodGet,
		},
		AppName: envs.AppNameAdmin(),
	}
	Policies = Obj{
		Name:     "policies",
		NeedRoot: true,
		Acts: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodDelete,
		},
		AppName: envs.AppNameAdmin(),
	}
	Departments = Obj{
		Name: "departments",
		Acts: []string{
			http.MethodGet,
			http.MethodPost,
			http.MethodPut,
		},
		AppName: envs.AppNameAdmin(),
	}
	Logs = Obj{
		Name:     "logs",
		NeedRoot: true,
		Acts: []string{
			http.MethodGet,
		},
		AppName: envs.AppNameAdmin(),
	}
)

Functions

func RBACEnforcer

func RBACEnforcer() *casbin.Enforcer

func SetupEnforcer

func SetupEnforcer(appCtx *app.AppContext)

Types

type Obj

type Obj struct {
	Name     string
	NeedRoot bool
	Acts     []string
	AppName  string
}

func GetObj

func GetObj(appName, name string) *Obj

func ObjList

func ObjList() []Obj

func (*Obj) Resource

func (obj *Obj) Resource() string

func (*Obj) Support

func (obj *Obj) Support(act string) bool

Jump to

Keyboard shortcuts

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