-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathirbac.go
31 lines (26 loc) · 841 Bytes
/
irbac.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package gorbac
type AssertionFunc func(RBAC, string, Permission) bool
type AssertionIDFunc func(RBAC, string, string) bool
type RBAC interface {
SetParents(string, []string) error
GetParents(string) ([]string, error)
SetParent(string, string) error
RemoveParent(string, string) error
AddRole(Role) error
RemoveRole(string) error
GetRole(string) (Role, []string, error)
GetRoleOnly(string) (Role, error)
IsGranted(string, Permission) bool
IsGrantedID(string, string) bool
IsAssertGranted(string, Permission, AssertionFunc) bool
IsAssertGrantedID(string, string, AssertionIDFunc) bool
}
// NewRBAC returns a RBAC structure.
// The default role structure will be used.
func NewRBAC() RBAC {
return &_RBAC{
roles: make(Roles),
permissions: make(Permissions),
parents: make(map[string]map[string]struct{}),
}
}