Documentation
¶
Index ¶
- Variables
- func IsScopedRole(role Role) bool
- func Roles() []string
- type Grant
- type Grants
- func (t Grants) AsStringList() []string
- func (t Grants) AssertRoleOn(scope string, roles ...Role) bool
- func (t Grants) Has(role Role, scope string) bool
- func (t Grants) HasGrant(grants ...Grant) bool
- func (t Grants) HasRole(roles ...Role) bool
- func (t Grants) HasRoleOn(scope string, roles ...Role) bool
- func (t Grants) Namespaces(roles ...Role) []string
- func (t Grants) String() string
- func (t Grants) WithRole(roles ...Role) (grants Grants)
- type Role
Constants ¶
This section is empty.
Variables ¶
View Source
var ( GrantRoot = NewGrant("root", "") GrantSquatter = NewGrant("squatter", "") GrantHeartbeat = NewGrant("heartbeat", "") GrantBlacklistAdmin = NewGrant("blacklistadmin", "") GrantJoin = NewGrant("join", "") GrantLeave = NewGrant("leave", "") GrantPrioritizer = NewGrant("prioritizer", "") )
Functions ¶
func IsScopedRole ¶
Types ¶
type Grants ¶
type Grants []Grant
Grants is a list of Grant
func FilterGrantStrings ¶
FilterGrantStrings return a subset of allowed grants capped by the requested role and scope.
1/ with no role and no scope,
return all user grants.
Request Request User Returned
Role Scope Grants Grants
--- --- --- ---
root root
admin admin
admin:ns1,admin:ns2,guest:ns3 admin:ns1,admin:ns2,guest:ns3
2/ with roles and scope,
Request Request User Returned Role Scope Grants Grants --- --- --- --- admin ns2 root admin:ns2 admin ns2 admin admin:ns2 guest ns2 admin guest:ns2 admin ns2 admin:ns1,admin:ns2,guest:ns3 admin:ns2 admin ns3 admin:ns1,admin:ns2,guest:ns3 guest ns2 admin:ns1,admin:ns2,guest:ns3 guest:ns2
3/ with roles and no scope,
Role Scope Grants Filtered Grants --- --- --- --- root root root admin root admin root admin admin admin admin guest admin guest root admin:ns1,admin:ns2,guest:ns3 admin admin:ns1,admin:ns2,guest:ns3 admin:ns1,admin:ns2 guest admin:ns1,admin:ns2,guest:ns3 guest:ns3
4/ with scope and no role,
Role Scope Grants Filtered Grants
--- --- --- ---
ns1 root admin:ns1
ns1 guest guest:ns1
ns1 admin:ns1,admin:ns2,guest:ns3 admin:ns1
ns3 admin:ns1,admin:ns2,guest:ns3 guest:ns3
func (Grants) AsStringList ¶
func (Grants) HasRoleOn ¶
HasRoleOn checks if any of the specified roles with the given scope exist in the Grants.
func (Grants) Namespaces ¶
type Role ¶
type Role string
const ( RoleUndef Role = "" RoleRoot Role = "root" RoleAdmin Role = "admin" RoleOperator Role = "operator" RolePrioritizer Role = "prioritizer" RoleGuest Role = "guest" RoleSquatter Role = "squatter" RoleBlacklistAdmin Role = "blacklistadmin" RoleHeartbeat Role = "heartbeat" RoleJoin Role = "join" RoleLeave Role = "leave" )
func SplitGrant ¶
SplitGrant extract role and scope from a grant
Click to show internal directories.
Click to hide internal directories.