Documentation
¶
Overview ¶
Index ¶
- Constants
- type AssertionFunc
- type BaseRole
- func (role *BaseRole) AddParent(name string)
- func (role *BaseRole) AddPermission(permission string)
- func (role *BaseRole) HasPermission(permission string) bool
- func (role *BaseRole) Name() string
- func (role *BaseRole) Parents() []string
- func (role *BaseRole) Permissions() []string
- func (role *BaseRole) RemoveParent(name string)
- func (role *BaseRole) Reset()
- func (role *BaseRole) RevokePermission(permission string)
- type Map
- type Rbac
- func (rbac *Rbac) Add(name string, permissions []string, parents []string)
- func (rbac *Rbac) Dump() Map
- func (rbac *Rbac) Get(name string) Role
- func (rbac *Rbac) IsGranted(name, permission string, assert AssertionFunc) bool
- func (rbac *Rbac) Remove(name string)
- func (rbac *Rbac) Set(name string, permissions []string, parents []string)
- type Role
- type RoleFactoryFunc
- type RoleMap
Constants ¶
View Source
const ( ParentKey = "parents" PermissionKey = "permissions" NameKey = "name" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssertionFunc ¶
Assertion function supplies more fine-grained permission controls.
type BaseRole ¶
type BaseRole struct {
// contains filtered or unexported fields
}
func (*BaseRole) AddPermission ¶
func (*BaseRole) HasPermission ¶
func (*BaseRole) Permissions ¶
func (*BaseRole) RemoveParent ¶
func (*BaseRole) RevokePermission ¶
type Rbac ¶
type Rbac struct {
// contains filtered or unexported fields
}
RBAC
func (*Rbac) Add ¶
Add a role with `name`. It has `permissions` and `parents`. If the role is not existing, a new one will be created. This function will add new permissions and parents to the role, and keep orignals.
type Role ¶
type Role interface {
Name() string
AddPermission(string)
HasPermission(string) bool
RevokePermission(string)
Permissions() []string
AddParent(string)
RemoveParent(string)
Parents() []string
Reset()
}
func NewBaseRole ¶
type RoleFactoryFunc ¶
Sometimes, a custom role structure is needed by projects. You should define your own role factory function for this purpuse.
Click to show internal directories.
Click to hide internal directories.