Versions in this module Expand all Collapse all v0 v0.0.4 Jun 6, 2019 v0.0.3 Jun 5, 2019 Changes in this version + var ErrFoundCircle = fmt.Errorf(`found circle`) + var ErrRoleExist = errors.New("role has already existed") + var ErrRoleNotExist = errors.New("role does not exist") + func AllGranted(rbac *RBAC, roles []string, permission Permission, assert AssertionFunc) (res bool) + func AnyGranted(rbac *RBAC, roles []string, permission Permission, assert AssertionFunc) (res bool) + func InheritanceCircle(rbac *RBAC) (err error) + func Walk(rbac *RBAC, h WalkHandler) (err error) + type AssertionFunc func(*RBAC, string, Permission) bool + type DeepPermission struct + IDStr string + Sep string + func (p *DeepPermission) ID() string + func (p *DeepPermission) Match(a Permission) bool + type Permission interface + ID func() string + Match func(Permission) bool + func NewDeepPermission(id string) Permission + func NewPermission(id string) Permission + type Permissions map[string]Permission + type RBAC struct + func New() *RBAC + func (rbac *RBAC) Add(r Role) (err error) + func (rbac *RBAC) GetParents(id string) ([]string, error) + func (rbac *RBAC) GetRole(id string) (r Role, parents []string, err error) + func (rbac *RBAC) GetRoles() []*Role + func (rbac *RBAC) IsGranted(id string, p Permission, assert AssertionFunc) (rslt bool) + func (rbac *RBAC) Permissions(id string) Permissions + func (rbac *RBAC) Remove(id string) (err error) + func (rbac *RBAC) RemoveParent(id string, parent string) error + func (rbac *RBAC) SetParent(id string, parent string) error + func (rbac *RBAC) SetParents(id string, parents []string) error + type Role interface + ID func() string + Permissions func() []Permission + Permit func(Permission) bool + type Roles map[string]Role + type SimplePermission struct + IDStr string + func (p *SimplePermission) ID() string + func (p *SimplePermission) Match(a Permission) bool + type SimpleRole struct + IDStr string + func NewRole(id string) *SimpleRole + func (role *SimpleRole) Assign(p Permission) *SimpleRole + func (role *SimpleRole) ID() string + func (role *SimpleRole) Permissions() []Permission + func (role *SimpleRole) Permit(p Permission) (res bool) + func (role *SimpleRole) Revoke(p Permission) error + type WalkHandler func(Role, []string) error