Version: v1.9.1 Latest Latest

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

Go to latest
Published: Jul 4, 2019 License: Apache-2.0 Imports: 7 Imported by: 241




This section is empty.


This section is empty.


This section is empty.


type Assertion

type Assertion struct {
	Key    string
	Value  string
	Tokens []string
	Policy [][]string
	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 Function

type Function func(args ...interface{}) (interface{}, error)

Function represents a function that is used in the matchers, used to get attributes in ABAC.

type FunctionMap

type FunctionMap map[string]func(args ...interface{}) (interface{}, error)

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

AddFunction adds an expression function.

type Model

type Model map[string]AssertionMap

Model represents the whole access control model.

func (Model) AddDef added in v0.8.0

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

AddDef adds an assertion to the model.

func (Model) AddPolicy

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

AddPolicy adds a policy rule to the model.

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

BuildRoleLinks initializes the roles in RBAC.

func (Model) ClearPolicy

func (model Model) ClearPolicy()

ClearPolicy clears all current policy.

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

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

GetPolicy gets all rules in a policy.

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) 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 added in v0.9.0

func (model Model) LoadModel(path string)

LoadModel loads the model from model CONF file.

func (Model) LoadModelFromText added in v0.9.0

func (model Model) LoadModelFromText(text string)

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

func (model Model) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) bool

RemoveFilteredPolicy removes policy rules based on field filters 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.

Jump to

Keyboard shortcuts

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