Documentation ¶
Overview ¶
Package permissions provides functionalities to calculate, update and merge arrays of permission domain rules.
Read this to get more information about how permission domains and rules are working: https://github.com/zekroTJA/shinpuru/wiki/Permissions-Guide
Index ¶
- type PermissionArray
- func (p PermissionArray) Check(domainName string) bool
- func (p PermissionArray) Equals(p2 PermissionArray) bool
- func (p PermissionArray) Merge(newPerms PermissionArray, override bool) PermissionArray
- func (p PermissionArray) Update(newPerm string, override bool) (newPermsArray PermissionArray, changed bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PermissionArray ¶
type PermissionArray []string
PermissionArray describes a set of permission rules.
Example:
+sp.guild.config.* +sp.* +sp.guild.* -sp.guild.mod.ban +sp.etc.* +sp.chat.*
func (PermissionArray) Check ¶
func (p PermissionArray) Check(domainName string) bool
Check returns true if the passed domainName matches positively on the permission array p.
func (PermissionArray) Equals ¶
func (p PermissionArray) Equals(p2 PermissionArray) bool
Equals returns true when p2 has the same elements in the same order as p.
func (PermissionArray) Merge ¶
func (p PermissionArray) Merge(newPerms PermissionArray, override bool) PermissionArray
Merge updates all entries of p using Update one by one with all entries of newPerms. Parameter override is passed to the Update function.
A new permissions array is returned with the resulting permission rule set.
func (PermissionArray) Update ¶
func (p PermissionArray) Update(newPerm string, override bool) (newPermsArray PermissionArray, changed bool)
Update "adds" the passed newPerm to the permission array p by merging the permissions and returns the result as new permission array.
This means, if p looks like following
+sp.guild.* +sp.guild.mod.ban
and newPerm is '-sp.guild.mod.ban', the returned permission array will be
+sp.guild.*