Documentation ¶
Index ¶
- type MatchingFunc
- type Role
- type RoleManager
- func (rm *RoleManager) AddDomainMatchingFunc(name string, fn MatchingFunc)
- func (rm *RoleManager) AddLink(name1 string, name2 string, domains ...string) error
- func (rm *RoleManager) AddMatchingFunc(name string, fn MatchingFunc)
- func (rm *RoleManager) BuildRelationship(name1, name2 string, domains ...string) error
- func (rm *RoleManager) Clear() error
- func (rm *RoleManager) DelDomain(domain string) (status bool)
- func (rm *RoleManager) DeleteLink(name1 string, name2 string, domains ...string) error
- func (rm *RoleManager) GetAllDomains() ([]string, error)
- func (rm *RoleManager) GetAllRolesInDomain(domain string) (roles []string)
- func (rm *RoleManager) GetDomains(name string) ([]string, error)
- func (rm *RoleManager) GetRoles(name string, domains ...string) ([]string, error)
- func (rm *RoleManager) GetUsers(name string, domain ...string) ([]string, error)
- func (rm *RoleManager) HasDomain(domain string) (status bool)
- func (rm *RoleManager) HasLink(name1 string, name2 string, domains ...string) (bool, error)
- func (rm *RoleManager) HasRole(role, domain string) bool
- func (rm *RoleManager) PrintRoles() error
- func (rm *RoleManager) SetLogger(logger log.Logger)
- type Roles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MatchingFunc ¶
type Role ¶
type Role struct {
// contains filtered or unexported fields
}
Role represents the data structure for a role in RBAC.
type RoleManager ¶
type RoleManager struct {
// contains filtered or unexported fields
}
RoleManager provides a default implementation for the RoleManager interface
func NewRoleManager ¶
func NewRoleManager(maxHierarchyLevel int) *RoleManager
NewRoleManager is the constructor for creating an instance of the default RoleManager implementation.
func (*RoleManager) AddDomainMatchingFunc ¶
func (rm *RoleManager) AddDomainMatchingFunc(name string, fn MatchingFunc)
AddDomainMatchingFunc support use domain pattern in g
func (*RoleManager) AddLink ¶
func (rm *RoleManager) AddLink(name1 string, name2 string, domains ...string) error
AddLink adds the inheritance link between role: name1 and role: name2. aka role: name1 inherits role: name2.
func (*RoleManager) AddMatchingFunc ¶
func (rm *RoleManager) AddMatchingFunc(name string, fn MatchingFunc)
AddMatchingFunc support use pattern in g
func (*RoleManager) BuildRelationship ¶
func (rm *RoleManager) BuildRelationship(name1, name2 string, domains ...string) error
func (*RoleManager) Clear ¶
func (rm *RoleManager) Clear() error
Clear clears all stored data and resets the role manager to the initial state.
func (*RoleManager) DelDomain ¶ added in v0.1.1
func (rm *RoleManager) DelDomain(domain string) (status bool)
DelDomain 删除领域
func (*RoleManager) DeleteLink ¶
func (rm *RoleManager) DeleteLink(name1 string, name2 string, domains ...string) error
DeleteLink deletes the inheritance link between role: name1 and role: name2. aka role: name1 does not inherit role: name2 any more.
func (*RoleManager) GetAllDomains ¶
func (rm *RoleManager) GetAllDomains() ([]string, error)
GetAllDomains gets all domains
func (*RoleManager) GetAllRolesInDomain ¶
func (rm *RoleManager) GetAllRolesInDomain(domain string) (roles []string)
GetAllRolesInDomain 获取域下所有角色
func (*RoleManager) GetDomains ¶
func (rm *RoleManager) GetDomains(name string) ([]string, error)
GetDomains gets domains that a user has
func (*RoleManager) GetRoles ¶
func (rm *RoleManager) GetRoles(name string, domains ...string) ([]string, error)
GetRoles gets the roles that a subject inherits.
func (*RoleManager) GetUsers ¶
func (rm *RoleManager) GetUsers(name string, domain ...string) ([]string, error)
GetUsers gets the users that inherits a subject. domain is an unreferenced parameter here, may be used in other implementations.
func (*RoleManager) HasDomain ¶
func (rm *RoleManager) HasDomain(domain string) (status bool)
func (*RoleManager) HasRole ¶
func (rm *RoleManager) HasRole(role, domain string) bool
func (*RoleManager) PrintRoles ¶
func (rm *RoleManager) PrintRoles() error
PrintRoles prints all the roles to log.
func (*RoleManager) SetLogger ¶
func (rm *RoleManager) SetLogger(logger log.Logger)
SetLogger sets role manager's logger.