policy

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: Apache-2.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReduceFuncMap = map[string]ReduceFunc{
	"(,check,)":          wrapCheck,
	"(,and_expr,)":       wrapCheck,
	"(,or_expr,)":        wrapCheck,
	"check,and,check":    makeAndExpr,
	"or_expr,and,check":  mixOrAndExpr,
	"and_expr,and,check": extendAndExpr,
	"check,or,check":     makeOrExpr,
	"and_expr,or,check":  makeOrExpr,
	"or_expr,or,check":   extendOrExpr,
	"not,check":          makeNotExpr,
}

Functions

func Authorize

func Authorize(req *restful.Request, res *restful.Response, action string) bool

func RegisterRules

func RegisterRules(e *Enforcer)

Types

type AndCheck

type AndCheck struct {
	// contains filtered or unexported fields
}

func NewAndCheck

func NewAndCheck(check1 BaseCheck, check2 BaseCheck) *AndCheck

func (*AndCheck) AddCheck

func (this *AndCheck) AddCheck(rule BaseCheck) *AndCheck

func (*AndCheck) Exec

func (this *AndCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*AndCheck) String

func (this *AndCheck) String() string

type BaseCheck

type BaseCheck interface {
	String() string
	Exec(target map[string]string, cred map[string]interface{}, enforcer Enforcer, currentRule string) bool
}

func NewFalseCheck

func NewFalseCheck() BaseCheck

func NewGenericCheck

func NewGenericCheck(kind string, match string) BaseCheck

func NewRoleCheck

func NewRoleCheck(kind string, match string) BaseCheck

func NewRuleCheck

func NewRuleCheck(kind string, match string) BaseCheck

func NewTrueCheck

func NewTrueCheck() BaseCheck

type DefaultRule

type DefaultRule struct {
	Name     string
	CheckStr string
}

type Enforcer

type Enforcer struct {
	Rules        map[string]BaseCheck
	DefaultRules []DefaultRule
	OverWrite    bool
}

func NewEnforcer

func NewEnforcer(overWrite bool) *Enforcer

func (*Enforcer) Authorize

func (e *Enforcer) Authorize(rule string, target map[string]string, cred map[string]interface{}) (bool, error)

func (*Enforcer) Enforce

func (e *Enforcer) Enforce(rule string, target map[string]string, cred map[string]interface{}) (bool, error)

func (*Enforcer) LoadPolicyFile

func (e *Enforcer) LoadPolicyFile(path string, forcedReload bool, overWrite bool) error

func (*Enforcer) LoadRules

func (e *Enforcer) LoadRules(forcedReload bool) error

func (*Enforcer) RegisterDefaults

func (e *Enforcer) RegisterDefaults(rules []DefaultRule)

func (*Enforcer) UpdateRules

func (e *Enforcer) UpdateRules(rules map[string]BaseCheck)

type FalseCheck

type FalseCheck struct{}

func (*FalseCheck) Exec

func (this *FalseCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*FalseCheck) String

func (this *FalseCheck) String() string

type GenericCheck

type GenericCheck struct {
	// contains filtered or unexported fields
}

func (*GenericCheck) Exec

func (this *GenericCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*GenericCheck) String

func (this *GenericCheck) String() string

type NewCheckFunc

type NewCheckFunc func(kind string, match string) BaseCheck

type NotCheck

type NotCheck struct {
	// contains filtered or unexported fields
}

func NewNotCheck

func NewNotCheck(check BaseCheck) *NotCheck

func (*NotCheck) Exec

func (this *NotCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*NotCheck) String

func (this *NotCheck) String() string

type OrCheck

type OrCheck struct {
	// contains filtered or unexported fields
}

func NewOrCheck

func NewOrCheck(check1 BaseCheck, check2 BaseCheck) *OrCheck

func (*OrCheck) AddCheck

func (this *OrCheck) AddCheck(rule BaseCheck) *OrCheck

func (*OrCheck) Exec

func (this *OrCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*OrCheck) PopCheck

func (this *OrCheck) PopCheck() (*OrCheck, BaseCheck)

func (*OrCheck) String

func (this *OrCheck) String() string

type ParseState

type ParseState struct {
	// contains filtered or unexported fields
}

func NewParseState

func NewParseState() *ParseState

func (*ParseState) Result

func (p *ParseState) Result() (interface{}, error)

func (*ParseState) Shift

func (p *ParseState) Shift(tok string, val interface{})

type ReduceFunc

type ReduceFunc func(args ...interface{}) []TokenPair

type RoleCheck

type RoleCheck struct {
	// contains filtered or unexported fields
}

func (*RoleCheck) Exec

func (this *RoleCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*RoleCheck) String

func (this *RoleCheck) String() string

type RuleCheck

type RuleCheck struct {
	// contains filtered or unexported fields
}

func (*RuleCheck) Exec

func (this *RuleCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*RuleCheck) String

func (this *RuleCheck) String() string

type Rules

type Rules struct {
	Rules map[string]BaseCheck
}

func NewRules

func NewRules(data []byte, defaultRule []DefaultRule) (*Rules, error)

func (*Rules) Load

func (r *Rules) Load(data []byte, defaultRules []DefaultRule) error

func (*Rules) String

func (r *Rules) String() string

type TokenPair

type TokenPair struct {
	// contains filtered or unexported fields
}

type TrueCheck

type TrueCheck struct {
	// contains filtered or unexported fields
}

func (*TrueCheck) Exec

func (this *TrueCheck) Exec(target map[string]string,
	cred map[string]interface{},
	enforcer Enforcer,
	currentRule string) bool

func (*TrueCheck) String

func (this *TrueCheck) String() string

Jump to

Keyboard shortcuts

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