Documentation ¶
Index ¶
- Constants
- type Assertion
- type AssertionMap
- type FunctionMap
- type Model
- func (model *Model) AddDef(sec string, key string, value string) bool
- func (model *Model) AddPolicies(sec string, ptype string, rules [][]string)
- func (model *Model) AddPoliciesWithAffected(sec string, ptype string, rules [][]string) [][]string
- func (model *Model) AddPolicy(sec string, ptype string, rule []string)
- func (model *Model) BuildIncrementalRoleLinks(rmMap map[string]rbac.RoleManager, op PolicyOp, sec string, ptype string, ...) error
- func (model *Model) BuildRoleLinks(rmMap map[string]rbac.RoleManager) (err error)
- func (model *Model) ClearPolicy()
- func (model *Model) Copy() *Model
- func (model *Model) GetAstBySecPType(sec, ptype string) (*Assertion, bool)
- func (model *Model) GetFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) [][]string
- func (model *Model) GetKey(sec string) (*AssertionMap, bool)
- func (model *Model) GetLogger() log.Logger
- func (model *Model) GetPolicy(sec string, ptype string) [][]string
- func (model *Model) GetValuesForFieldInPolicy(sec string, ptype string, fieldIndex int) []string
- func (model *Model) GetValuesForFieldInPolicyAllTypes(sec string, fieldIndex int) []string
- func (model *Model) HasPolicies(sec string, ptype string, rules [][]string) bool
- func (model *Model) HasPolicy(sec string, ptype string, rule []string) bool
- func (model *Model) LoadModel(path string) error
- func (model *Model) LoadModelFromText(text string) error
- func (model *Model) PrintModel()
- func (model *Model) PrintPolicy()
- func (model *Model) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) (bool, [][]string)
- func (model *Model) RemovePolicies(sec string, ptype string, rules [][]string) bool
- func (model *Model) RemovePoliciesWithEffected(sec string, ptype string, rules [][]string) [][]string
- func (model *Model) RemovePolicy(sec string, ptype string, rule []string) bool
- func (model *Model) SetLogger(logger log.Logger)
- func (model *Model) SortPoliciesByPriority() error
- func (model *Model) SortPoliciesBySubjectHierarchy() (err error)
- func (model *Model) ToText() string
- func (model *Model) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) bool
- func (model *Model) UpdatePolicy(sec string, ptype string, oldRule []string, newRule []string) bool
- type PolicyOp
Constants ¶
const DefaultSep = ","
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertion ¶
type Assertion struct { Key string Value string Tokens []string Policy [][]string PolicyMap *sync.Map RM rbac.RoleManager // contains filtered or unexported fields }
Assertion represents an expression in a section of the model. For example: r = sub, obj, act
type AssertionMap ¶
AssertionMap is the collection of assertions, can be "r", "p", "g", "e", "m". type AssertionMap map[string]*Assertion
type FunctionMap ¶
type FunctionMap struct {
// contains filtered or unexported fields
}
FunctionMap represents the collection of Function.
func LoadFunctionMap ¶
func LoadFunctionMap() FunctionMap
LoadFunctionMap loads an initial function map.
func (*FunctionMap) AddFunction ¶
func (fm *FunctionMap) AddFunction(name string, function govaluate.ExpressionFunction)
AddFunction adds an expression function.
func (*FunctionMap) GetFunctions ¶
func (fm *FunctionMap) GetFunctions() map[string]govaluate.ExpressionFunction
GetFunctions return a map with all the functions
type Model ¶
Model represents the whole access control model. type Model map[string]AssertionMap
func NewModelFromFile ¶
NewModelFromFile creates a model from a .CONF file.
func NewModelFromString ¶
NewModelFromString creates a model from a string which contains model text.
func (*Model) AddPolicies ¶
AddPolicies adds policy rules to the model.
func (*Model) AddPoliciesWithAffected ¶
AddPoliciesWithAffected adds policy rules to the model, and returns effected rules.
func (*Model) BuildIncrementalRoleLinks ¶
func (model *Model) BuildIncrementalRoleLinks(rmMap map[string]rbac.RoleManager, op PolicyOp, sec string, ptype string, rules [][]string) error
BuildIncrementalRoleLinks provides incremental build the role inheritance relations.
func (*Model) BuildRoleLinks ¶
func (model *Model) BuildRoleLinks(rmMap map[string]rbac.RoleManager) (err error)
BuildRoleLinks initializes the roles in RBAC.
func (*Model) ClearPolicy ¶
func (model *Model) ClearPolicy()
ClearPolicy clears all current policy.
func (*Model) GetAstBySecPType ¶
func (*Model) GetFilteredPolicy ¶
func (model *Model) GetFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) [][]string
GetFilteredPolicy gets rules based on field filters from a policy.
func (*Model) GetValuesForFieldInPolicy ¶
GetValuesForFieldInPolicy gets all values for a field for all rules in a policy, duplicated values are removed.
func (*Model) GetValuesForFieldInPolicyAllTypes ¶
GetValuesForFieldInPolicyAllTypes gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.
func (*Model) HasPolicies ¶
HasPolicies determines whether a model has any of the specified policies. If one is found we return true.
func (*Model) LoadModelFromText ¶
LoadModelFromText loads the model from the text.
func (*Model) RemoveFilteredPolicy ¶
func (model *Model) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) (bool, [][]string)
RemoveFilteredPolicy removes policy rules based on field filters from the model.
func (*Model) RemovePolicies ¶
RemovePolicies removes policy rules from the model.
func (*Model) RemovePoliciesWithEffected ¶
func (model *Model) RemovePoliciesWithEffected(sec string, ptype string, rules [][]string) [][]string
RemovePoliciesWithEffected removes policy rules from the model, and returns effected rules.
func (*Model) RemovePolicy ¶
RemovePolicy removes a policy rule from the model. Deprecated: Using AddPoliciesWithAffected instead.
func (*Model) SortPoliciesByPriority ¶
func (*Model) SortPoliciesBySubjectHierarchy ¶
func (*Model) UpdatePolicies ¶
UpdatePolicies updates a policy rule from the model.