Documentation ¶
Index ¶
- Variables
- type Options
- type Perm
- type Rbac
- func (a *Rbac) AssignPerms(roleName string, permNames ...string) error
- func (a *Rbac) AssignRole(userID uint, roleName string) error
- func (a *Rbac) CheckPerm(userID uint, permName string) (bool, error)
- func (a *Rbac) CheckRole(userID uint, roleName string) (bool, error)
- func (a *Rbac) CheckRolePerm(roleName string, permName string) (bool, error)
- func (a *Rbac) DeletePerm(permName string) error
- func (a *Rbac) DeleteRole(roleName string) error
- func (a *Rbac) GetPerms() ([]string, error)
- func (a *Rbac) GetRoles() ([]string, error)
- func (a *Rbac) GetUserRoles(userID uint) ([]string, error)
- func (a *Rbac) NewPerm(permName string) error
- func (a *Rbac) NewRole(roleName string) error
- func (a *Rbac) RevokePerm(userID uint, permName string) error
- func (a *Rbac) RevokeRole(userID uint, roleName string) error
- func (a *Rbac) RevokeRolePerm(roleName string, permName string) error
- type Role
- type RolePerm
- type UserRole
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Rbac ¶
Rbac helps deal with permissions
func (*Rbac) AssignPerms ¶
AssignPerms assigns a group of permissions to a given role it accepts in the first parameter the role name, it returns an error if there is not matching record of the role name in the database. the second parameter is a slice of strings which represents a group of permissions to be assigned to the role if any of these permissions doesn't have a matching record in the database the operations stops, changes reverted and error is returned in case of success nothing is returned
func (*Rbac) AssignRole ¶
AssignRole assigns a given role to a user the first parameter is the user id, the second parameter is the role name if the role name doesn't have a matching record in the data base an error is returned if the user have already a role assigned to him an error is returned
func (*Rbac) CheckPerm ¶
CheckPerm checks if a permission is assigned to the role that's assigned to the user. it accepts the user id as the first parameter the permission as the second parameter it returns an error if the permission is not present in the database
func (*Rbac) CheckRole ¶
CheckRole checks if a role is assigned to a user it accepts the user id as the first parameter the role as the second parameter it returns an error if the role is not present in database.
func (*Rbac) CheckRolePerm ¶
CheckRolePerm checks if a role has the permission assigned it accepts the role as the first parameter it accepts the permission as the second parameter it returns an error if the role is not present in database it returns an error if the permission is not present in database
func (*Rbac) DeletePerm ¶
DeletePerm deletes a given permission if the permission is assigned to a role it returns an error.
func (*Rbac) DeleteRole ¶
DeleteRole deletes a given role if the role is assigned to a user it returns an error
func (*Rbac) GetUserRoles ¶
GetUserRoles returns all user assigned roles
func (*Rbac) RevokePerm ¶
RevokePerm revokes a permission from the user's assigned role it returns an error in case of any
func (*Rbac) RevokeRole ¶
RevokeRole revokes a user's role it returns a error in case of any