casbin: Index | Files

package model

import ""


Package Files

assertion.go function.go model.go policy.go


var DefaultSep = ","

type Assertion Uses

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 Uses

type AssertionMap map[string]*Assertion

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

type FunctionMap Uses

type FunctionMap struct {
    // contains filtered or unexported fields

FunctionMap represents the collection of Function.

func LoadFunctionMap Uses

func LoadFunctionMap() FunctionMap

LoadFunctionMap loads an initial function map.

func (*FunctionMap) AddFunction Uses

func (fm *FunctionMap) AddFunction(name string, function govaluate.ExpressionFunction)

AddFunction adds an expression function.

func (*FunctionMap) GetFunctions Uses

func (fm *FunctionMap) GetFunctions() map[string]govaluate.ExpressionFunction

GetFunctions return a map with all the functions

type Model Uses

type Model map[string]AssertionMap

Model represents the whole access control model.

func NewModel Uses

func NewModel() Model

NewModel creates an empty model.

func NewModelFromFile Uses

func NewModelFromFile(path string) (Model, error)

NewModelFromFile creates a model from a .CONF file.

func NewModelFromString Uses

func NewModelFromString(text string) (Model, error)

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

func (Model) AddDef Uses

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

AddDef adds an assertion to the model.

func (Model) AddPolicies Uses

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

AddPolicies adds policy rules to the model.

func (Model) AddPolicy Uses

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 Uses

func (model Model) ClearPolicy()

ClearPolicy clears all current policy.

func (Model) GetFilteredPolicy Uses

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 Uses

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

GetPolicy gets all rules in a policy.

func (Model) GetValuesForFieldInPolicy Uses

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 Uses

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 Uses

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 Uses

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

HasPolicy determines whether a model has the specified policy rule.

func (Model) LoadModel Uses

func (model Model) LoadModel(path string) error

LoadModel loads the model from model CONF file.

func (Model) LoadModelFromText Uses

func (model Model) LoadModelFromText(text string) error

LoadModelFromText loads the model from the text.

func (Model) PrintModel Uses

func (model Model) PrintModel()

PrintModel prints the model to the log.

func (Model) PrintPolicy Uses

func (model Model) PrintPolicy()

PrintPolicy prints the policy to log.

func (Model) RemoveFilteredPolicy Uses

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 Uses

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

RemovePolicies removes policy rules from the model.

func (Model) RemovePolicy Uses

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

RemovePolicy removes a policy rule from the model.

type PolicyOp Uses

type PolicyOp int
const (
    PolicyAdd PolicyOp = iota

Package model imports 10 packages (graph) and is imported by 52 packages. Updated 2020-07-04. Refresh now. Tools for package owners.