model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RULE_ADDED   = "rule_added"
	RULE_REMOVED = "rule_removed"
)
View Source
const (
	R_SEC = 'r'
	P_SEC = 'p'
	G_SEC = 'g'
	M_SEC = 'm'
	E_SEC = 'e'
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IModel

type IModel interface {
	api.IAddRuleBool
	api.IRemoveRuleBool
	api.IRangeRules
	api.IAddRemoveListener

	GetDef(sec byte, key string) (defs.IDef, bool)
	SetDef(sec byte, key string, value string) error
	RemoveDef(sec byte, key string) error

	GetRoleManager(key string) (rbac.IRoleManager, bool)
	SetRoleManager(key string, rm rbac.IRoleManager)

	GetPolicy(key string) (p.IPolicy, bool)
	SetPolicy(key string, policy p.IPolicy)

	GetEffector(key string) (e.IEffector, bool)
	SetEffector(key string, eft e.IEffector)

	GetMatcher(key string) (m.IMatcher, bool)
	SetMatcher(key string, matcher m.IMatcher)

	GetRequestDef(key string) (*defs.RequestDef, bool)
	SetRequestDef(key string, def *defs.RequestDef)

	ClearPolicy(key string) error

	SetFunction(name string, function govaluate.ExpressionFunction)
	RemoveFunction(name string) bool

	BuildMatcherFromDef(mDef *defs.MatcherDef) (matcher.IMatcher, error)

	RangeMatches(matcher matcher.IMatcher, rDef *defs.RequestDef, rvals []interface{}, fn func(rule []string) bool) error

	String() string
}

type Model

type Model struct {
	*em.Emitter
	// contains filtered or unexported fields
}

func NewModel

func NewModel() *Model

func NewModelFromFile

func NewModelFromFile(path string) (*Model, error)

func (*Model) AddRule

func (m *Model) AddRule(rule []string) (bool, error)

func (*Model) BuildMatcher

func (m *Model) BuildMatcher(key string) error

func (*Model) BuildMatcherFromDef

func (m *Model) BuildMatcherFromDef(mDef *defs.MatcherDef) (matcher.IMatcher, error)

func (*Model) BuildMatchers

func (m *Model) BuildMatchers() error

func (*Model) ClearPolicy

func (m *Model) ClearPolicy(pKey string) error

func (*Model) GetDef

func (m *Model) GetDef(sec byte, key string) (defs.IDef, bool)

func (*Model) GetEffector

func (m *Model) GetEffector(key string) (e.IEffector, bool)

func (*Model) GetMatcher

func (m *Model) GetMatcher(key string) (matcher.IMatcher, bool)

func (*Model) GetPolicy

func (m *Model) GetPolicy(key string) (policy.IPolicy, bool)

func (*Model) GetRequestDef

func (m *Model) GetRequestDef(key string) (*defs.RequestDef, bool)

func (*Model) GetRoleManager

func (m *Model) GetRoleManager(key string) (rbac.IRoleManager, bool)

func (*Model) LoadModel

func (m *Model) LoadModel(path string) error

LoadModel loads the model from model CONF file.

func (*Model) LoadModelFromText

func (m *Model) LoadModelFromText(text string) error

LoadModelFromText loads the model from the text.

func (*Model) RangeMatches

func (m *Model) RangeMatches(matcher matcher.IMatcher, rDef *defs.RequestDef, rvals []interface{}, fn func(rule []string) bool) error

func (*Model) RangeRules

func (m *Model) RangeRules(fn func(rule []string) bool)

func (*Model) RemoveDef

func (m *Model) RemoveDef(sec byte, key string) error

func (*Model) RemoveFunction

func (m *Model) RemoveFunction(name string) bool

func (*Model) RemoveRule

func (m *Model) RemoveRule(rule []string) (bool, error)

func (*Model) SetDef

func (m *Model) SetDef(sec byte, key string, value string) error

func (*Model) SetEffector

func (m *Model) SetEffector(key string, effector e.IEffector)

func (*Model) SetFunction

func (m *Model) SetFunction(name string, function govaluate.ExpressionFunction)

func (*Model) SetMatcher

func (m *Model) SetMatcher(key string, matcher matcher.IMatcher)

func (*Model) SetPolicy

func (m *Model) SetPolicy(key string, policy policy.IPolicy)

func (*Model) SetRequestDef

func (m *Model) SetRequestDef(key string, def *defs.RequestDef)

func (*Model) SetRoleManager

func (m *Model) SetRoleManager(key string, rm rbac.IRoleManager)

func (*Model) String

func (m *Model) String() string

type SectionDef

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

func NewSectionDef

func NewSectionDef(name string, keyPrefix byte, handler func(m *Model, key, value string) error, removeHandler func(m *Model, key string) error) *SectionDef

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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