Documentation ¶
Index ¶
- Variables
- type Perm
- type Perms
- func (p Perms) CheckAllPerms(permsToCheck []string, requiredPerms []Perm) bool
- func (p Perms) CheckAnyPerm(permsToCheck []string, requiredPerms []Perm) bool
- func (p Perms) CheckPerm(permsToCheck []string, requiredPerm Perm) bool
- func (p Perms) GetPermByName(name string) (Perm, bool)
- func (p Perms) PermNames() []string
- func (p Perms) String() string
Constants ¶
This section is empty.
Variables ¶
var PermBAC = Perms{ PermRoot, }
PermBAC is the instance of the PermBAC access control model.
var PermRoot = Perm{
Name: "*",
Desc: "Has all permissions",
}
PermRoot Has all permissions
Name: *
Functions ¶
This section is empty.
Types ¶
type Perm ¶
type Perm struct { Name string `json:"name" param:"name" query:"name" form:"name" xml:"name" csv:"name"` Desc string `json:"desc" param:"desc" query:"desc" form:"desc" xml:"desc" csv:"desc"` }
Perm represents a permission.
Can be associated directly with a user or can be associated with a role that is then associated with a user, it's up to you how you want to implement it.
type Perms ¶
type Perms []Perm
Perms is a slice of permissions
Can be associated directly with a user or can be associated with a role that is then associated with a user, it's up to you how you want to implement it.
func (Perms) CheckAllPerms ¶
CheckAllPerms checks if a list of user perm names are contained in another list of required perms.
Returns true if all required perms are contained in the user perms list.
Also returns true if the root permission is found.
func (Perms) CheckAnyPerm ¶
CheckAnyPerm checks if any of the required perms are contained in the user perms list.
Returns true if any of the required perms is found in the user perms list.
Also returns true if the root permission is found.
func (Perms) CheckPerm ¶
CheckPerm checks if a list of user perm names contains a required perm.
Returns true if the required perm is contained.
Also returns true if the root permission is found.
func (Perms) GetPermByName ¶
GetPermByName returns the Perm with the given name and a boolean indicating if it was found.