model

package
v3.0.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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 map[string]int
	RM        rbac.RoleManager
}

Assertion represents an expression in a section of the model. For example: r = sub, obj, act

type AssertionMap

type AssertionMap map[string]*Assertion

AssertionMap is the collection of assertions, can be "r", "p", "g", "e", "m".

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

type Model map[string]AssertionMap

Model represents the whole access control model.

func NewModel

func NewModel() Model

NewModel creates an empty model.

func NewModelFromFile

func NewModelFromFile(path string) (Model, error)

NewModelFromFile creates a model from a .CONF file.

func NewModelFromString

func NewModelFromString(text string) (Model, error)

NewModelFromString creates a model from a string which contains model text.

func (Model) AddDef

func (model Model) AddDef(sec string, key string, value string) bool

AddDef adds an assertion to the model.

func (Model) AddPolicies

func (model Model) AddPolicies(sec string, ptype string, rules [][]string)

AddPolicies adds policy rules to the model.

func (Model) AddPolicy

func (model Model) AddPolicy(sec string, ptype string, rule []string)

AddPolicy adds a policy rule to the model.

func (model Model) BuildIncrementalRoleLinks(rm rbac.RoleManager, op PolicyOp, sec string, ptype string, rules [][]string) error

BuildIncrementalRoleLinks provides incremental build the role inheritance relations.

func (model Model) BuildRoleLinks(rm rbac.RoleManager) error

BuildRoleLinks initializes the roles in RBAC.

func (Model) ClearPolicy

func (model Model) ClearPolicy()

ClearPolicy clears all current policy.

func (Model) GenerateFunctions

func (model Model) GenerateFunctions(fm FunctionMap) map[string]govaluate.ExpressionFunction

GenerateFunctions return a map with all the functions

func (Model) GetEffectExpression

func (model Model) GetEffectExpression() string

GetEffectExpression gets the effect expression.

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) GetMatcher

func (model Model) GetMatcher() string

GetMatcher gets the matcher.

func (Model) GetPolicy

func (model Model) GetPolicy(sec string, ptype string) [][]string

GetPolicy gets all rules in a policy.

func (Model) GetPtypes

func (model Model) GetPtypes(sec string) []string

GetPtypes returns a slice for all ptype

func (Model) GetRoleManager

func (model Model) GetRoleManager(sec string, ptype string) rbac.RoleManager

GetRoleManager gets the current role manager used in ptype.

func (Model) GetTokens

func (model Model) GetTokens(sec string, ptype string) map[string]int

GetTokens returns a map with all the tokens

func (Model) GetValuesForFieldInPolicy

func (model Model) GetValuesForFieldInPolicy(sec string, ptype string, fieldIndex int) []string

GetValuesForFieldInPolicy gets all values for a field for all rules in a policy, duplicated values are removed.

func (Model) GetValuesForFieldInPolicyAllTypes

func (model Model) GetValuesForFieldInPolicyAllTypes(sec string, fieldIndex int) []string

GetValuesForFieldInPolicyAllTypes gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.

func (Model) HasPolicies

func (model Model) HasPolicies(sec string, ptype string, rules [][]string) bool

HasPolicies determines whether a model has any of the specified policies. If one is found we return false.

func (Model) HasPolicy

func (model Model) HasPolicy(sec string, ptype string, rule []string) bool

HasPolicy determines whether a model has the specified policy rule.

func (Model) LoadModel

func (model Model) LoadModel(path string) error

LoadModel loads the model from model CONF file.

func (Model) LoadModelFromText

func (model Model) LoadModelFromText(text string) error

LoadModelFromText loads the model from the text.

func (Model) PrintModel

func (model Model) PrintModel()

PrintModel prints the model to the log.

func (Model) PrintPolicy

func (model Model) PrintPolicy()

PrintPolicy prints the policy to log.

func (Model) RemoveExistPolicy

func (model Model) RemoveExistPolicy(sec string, ptype string, rules [][]string) [][]string

RemoveExistPolicy remove the policy rules already in the model.

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) RemoveNotExistPolicy

func (model Model) RemoveNotExistPolicy(sec string, ptype string, rules [][]string) [][]string

RemoveNotExistPolicy removes the policy rules not in the model

func (Model) RemovePolicies

func (model Model) RemovePolicies(sec string, ptype string, rules [][]string) bool

RemovePolicies removes policy rules from the model.

func (Model) RemovePolicy

func (model Model) RemovePolicy(sec string, ptype string, rule []string) bool

RemovePolicy removes a policy rule from the model.

type PolicyOp

type PolicyOp int
const (
	PolicyAdd PolicyOp = iota
	PolicyRemove
)

Jump to

Keyboard shortcuts

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