Documentation ¶
Index ¶
- Variables
- func RoleDomainMatchEqual(request, mapping string) bool
- type Assertion
- type AssertionSchema
- type Effector
- type ExtensionFunc
- type LoadIterator
- type Matcher
- type Matchers
- type MatchersConfig
- type Model
- type Policies
- type PolicyEvalFunc
- type RoleDomainMatchFunc
- type RoleMapping
- type RoleMappings
- type RoleSchema
- type RoleType
- type RolesSchema
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFoundMatcher = errors.New("not found specified matcher") ErrInvalidAssertionSchema = errors.New("invalid assertion schema") ErrInvalidAssertion = errors.New("invalid assertion") ErrInvalidMatchersConfig = errors.New("invalid matchers config") ErrInvalidRoleTypeDefinition = errors.New("invalid role type definition") ErrRoleMappingMismatchRoleType = errors.New("role mapping mismatch role type") ErrUnknownAssertionType = errors.New("unknown assertion type") ErrNotFoundSpecifiedRoleMappingGroup = errors.New("not found role mapping group") ErrUnexpectedEvalResult = errors.New("expected eval result") )
Functions ¶
func RoleDomainMatchEqual ¶
Types ¶
type AssertionSchema ¶
type AssertionSchema struct {
// contains filtered or unexported fields
}
AssertionSchema is assertion schema definition.
Define the fields that the assertion has.
func NewAssertionSchema ¶
func NewAssertionSchema(line string) (schema AssertionSchema, err error)
NewAssertionSchema constructes an assertion schema from a casbin definition line.
func (AssertionSchema) CreateAssertion ¶
func (s AssertionSchema) CreateAssertion(vals []string) (assertion Assertion, err error)
CreateAssertion creates an assertion.
CreateAssertion would verify if the input vals is matched with the schema.
func (AssertionSchema) CreateAssertions ¶ added in v0.2.0
func (s AssertionSchema) CreateAssertions(policies [][]string) (assertions Policies, err error)
CreateAssertions creates a list of assertion from raw policies.
func (*AssertionSchema) Has ¶
func (s *AssertionSchema) Has(key string) bool
Has returns if the assertion schema has a field with the specified key.
type Effector ¶
type Effector interface {
Execute(eval PolicyEvalFunc, policies Policies) (allow bool, err error)
}
Effector interface.
type LoadIterator ¶
type LoadIterator interface { // Next returns next policy or role mapping. // // The `key` may be `p` or a role mapping key like `g`. // If `ok` is false. There is no more data or an error. Next() (ok bool, key string, vals []string) // Error returns the error that has occurred in `Next()` calling. Error() (err error) }
The iterator interface for loading policies and role mappings.
type MatchersConfig ¶
type MatchersConfig struct { Roles RolesSchema Define map[string]string ExtensionFuncs []ExtensionFunc }
func (MatchersConfig) New ¶
func (c MatchersConfig) New() (m Matchers, err error)
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is casbin model schema.
func NewModel ¶
func NewModel( policy, request AssertionSchema, roles RolesSchema, effector Effector, matchers Matchers, ) (m *Model)
NewModel constructes a new Model.
func (*Model) Load ¶
func (m *Model) Load(itr LoadIterator) ( policies Policies, roleMappings RoleMappings, err error, )
Load load and returns the policies and role mappings by an assertion iterator.
Load would check the loaded data if it is matched with the model.
func (*Model) Policy ¶
func (m *Model) Policy() AssertionSchema
Policy returns the policy assertion schema.
func (*Model) Request ¶
func (m *Model) Request() AssertionSchema
Request returns the request assertion schema.
type PolicyEvalFunc ¶
type RoleDomainMatchFunc ¶
type RoleMapping ¶
type RoleMapping struct {
// contains filtered or unexported fields
}
func NewRoleMapping ¶
func NewRoleMapping(key string, domainMatch RoleDomainMatchFunc) *RoleMapping
func (*RoleMapping) GenerateGFunc ¶
func (rg *RoleMapping) GenerateGFunc(moreGraphs ...*graph.Graph) (overload *functions.Overload)
func (*RoleMapping) Key ¶
func (rg *RoleMapping) Key() string
type RoleSchema ¶
type RoleSchema struct { Type RoleType DomainMatchFunc RoleDomainMatchFunc }
type RoleType ¶
type RoleType int
Role mapping type.
func RoleTypeFromLine ¶
Get the role type from the definition in official casbin format.
* "_, _" is without domain. * "_, _, _" is with domain.
type RolesSchema ¶
type RolesSchema map[string]RoleSchema