Documentation ¶
Index ¶
- func GetDB(opts Options) *gorm.DB
- func MigrateTables(opts Options)
- type Authority
- func (a *Authority) AssignDefaultRolePermissions(roleID uint, userID uint) []string
- func (a *Authority) AssignDefaultRolePermissionsUUID(roleID uint, userID uuid.UUID) []string
- func (a *Authority) AssignPermissionsToCategory(categoryID uint, permissions []uint) []string
- func (a *Authority) AssignRole(userID uint, roleID uint) error
- func (a *Authority) AssignRolePermissions(roleID uint, permissionIDs []uint) []string
- func (a *Authority) AssignRoleUUID(userID uuid.UUID, roleID uint) error
- func (a *Authority) AssignUserPermissions(userID uint, permissionIDs []uint) []string
- func (a *Authority) AssignUserPermissionsUUID(userID uuid.UUID, permissionIDs []uint) []string
- func (a *Authority) CheckPermission(userID uint, permissionID uint) (bool, error)
- func (a *Authority) CheckPermissionUUID(userID uuid.UUID, permName string) (bool, error)
- func (a *Authority) CheckRole(userID uint, roleID uint) (bool, error)
- func (a *Authority) CheckRolePermission(roleID uint, permissionID uint) (bool, error)
- func (a *Authority) CheckRoleUUID(userID uuid.UUID, roleID uint) (bool, error)
- func (a *Authority) CreateCategory(categoryName string) error
- func (a *Authority) CreatePermission(permissionName string, description string, url_id uint) error
- func (a *Authority) CreateRole(roleName string) error
- func (a *Authority) CreateStaticPermission(permissionID uint, permissionData []string) error
- func (a *Authority) CreateStaticPermissionCategory(categoryID uint, categoryName string) error
- func (a *Authority) CreateStaticPermissionUrl(urlID uint, urlPath string) error
- func (a *Authority) CreateStaticRole(roleID uint, roleName string) error
- func (a *Authority) DeleteCategory(categoryID uint) error
- func (a *Authority) DeletePermission(permissionID uint) error
- func (a *Authority) DeleteRole(roleID uint) error
- func (a *Authority) GetCategories() ([]models.Category, error)
- func (a *Authority) GetCategoryPermissions() ([]domain.CategoryPermissionsResponse, error)
- func (a *Authority) GetPermissions() ([]models.Permission, error)
- func (a *Authority) GetPermissionsByCategory(categoryID uint) ([]models.Permission, error)
- func (a *Authority) GetRoles() ([]models.Role, error)
- func (a *Authority) GetUserRoles(userID uint) ([]models.Role, error)
- func (a *Authority) GetUserRolesUUID(userID uuid.UUID) ([]models.Role, error)
- func (a *Authority) RevokePermission(userID uint, permName string) error
- func (a *Authority) RevokePermissionUUID(userID uuid.UUID, permName string) error
- func (a *Authority) RevokeRole(userID uint, roleID uint) error
- func (a *Authority) RevokeRolePermission(roleID uint, permissionID uint) error
- func (a *Authority) RevokeRoleUUID(userID uuid.UUID, roleID uint) error
- func (a *Authority) UpdateCategory(categoryID uint, categoryName string) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateTables ¶
func MigrateTables(opts Options)
Types ¶
type Authority ¶
Authority helps deal with permissions
func (*Authority) AssignDefaultRolePermissions ¶
AssignDefaultRolePermissions assigns the default permissions associated with the role to a user.
It takes in two uint parameters: roleID and userID and returns an error object.
func (*Authority) AssignDefaultRolePermissionsUUID ¶
AssignDefaultRolePermissions assigns the default permissions associated with the role to a user.
It takes in two parameters: roleID of type uint and userID of type uuid.UUID and returns an error object.
func (*Authority) AssignPermissionsToCategory ¶
AssignPermissionsToCategory associates permission(s) with a category.
It takes in two parameters: categoryID of type uint and permissions of type slice of uint and returns an error object.
func (*Authority) AssignRole ¶
AssignRole associates a user with the role with the given role id.
It takes in two uint type parameters: userID and roleID and returns an error object.
func (*Authority) AssignRolePermissions ¶
AssignRolePermissions assign a list of permissions to a specified role.
It takes in two parameters: roleID of type uint and permissionIDs of type slice of uint and return an error object.
func (*Authority) AssignRoleUUID ¶
AssignRoleUUID associates a user with the role with the given role id.
It takes in userID, a uuid.UUID and roleID, an uint and returns an error object.
func (*Authority) AssignUserPermissions ¶
AssignUserPermissions assigns permission(s) to a specified user.
It takes in two parameters: userID of type uint and permissionIDs of type slice of uint and returns an error object.
func (*Authority) AssignUserPermissionsUUID ¶
AssignUserPermissions assigns permission(s) to a specified user.
It takes in two parameters: userID of type uuid.UUID and permissionIDs of type slice of uint and returns an error object.
func (*Authority) CheckPermission ¶
CheckPermission checks if a user has a specified permission.
It takes in two parameters: userID of type uint and permName of type string. It returns a boolean and an error object.
func (*Authority) CheckPermissionUUID ¶
CheckPermission checks if a user has a specified permission.
It takes in two parameters: userID of type uuid.UUID and permName of type string. It returns a boolean and an error object.
func (*Authority) CheckRole ¶
CheckRole checks if a role is assigned to a user.
It takes in two uint parameters: userID and roleID. It returns a boolean to specify that a role is assigned to a user and an error object.
func (*Authority) CheckRolePermission ¶
CheckRolePermission checks if a permission is associated the role.
It takes in two uint parameters: roleID and permissionID. It returns a boolean and an error object.
func (*Authority) CheckRoleUUID ¶
CheckRole checks if a role is assigned to a user.
It takes in two parameters: userID of type uuid.UUID and roleID of type uint. It returns a boolean to specify that a role is assigned to a user and an error object.
func (*Authority) CreateCategory ¶
CreateCategory creates a new category with the specified name.
It takes a string parameter, categoryName and returns an error object.
func (*Authority) CreatePermission ¶
CreatePermission creates a new permission with the specified permission name and description.
It takes two string parameter, permissionName and description and returns an error object.
func (*Authority) CreateRole ¶
CreateRole creates a new role with the specified role name.
It takes a string parameter, roleName and returns an error object.
func (*Authority) CreateStaticPermission ¶
CreateStaticPermission creates a new permission with the specified id and permission data. (Prefer using this function only if a self-defined uint type ID needs to be passed to create a permission.)
It takes two parameters: permissionID of uint type and permissionData which includes name and description for a new permission and returns an error object.
func (*Authority) CreateStaticPermissionCategory ¶
CreateStaticPermissionCategory creates a new category with the specified id and name. (Prefer using this function only if a self-defined uint type ID needs to be passed to create a category.)
It takes two parameters: categoryID of uint type and categoryName of type string and returns an error object.
func (*Authority) CreateStaticPermissionUrl ¶
CreateStaticPermissionUrl creates a new url with the specified id and permission url path. (Prefer using this function only if a self-defined uint type ID needs to be passed to create a url.)
It takes two parameters: urlID of uint type and urlPath of string type and returns an error object.
func (*Authority) CreateStaticRole ¶
CreateStaticRole creates a new role with the specified id and role name.
It takes two paraeters: roleID of uint type and roleName of string type and returns an error object. (Prefer using this function only if a self-defined uint type ID needs to be passed to create a role.)
func (*Authority) DeleteCategory ¶
DeleteCategory deletes a category with the specified category id.
It takes an uint parameter, categoryID and returns an error object.
func (*Authority) DeletePermission ¶
DeletePermission deletes a permission with the specified permission id.
It takes an uint parameter, permissionID and returns an error object.
func (*Authority) DeleteRole ¶
DeleteRole deletes a role with the specified role id, roleID.
It takes an uint parameter, roleID and returns an error object.
func (*Authority) GetCategories ¶
GetCategories retrieves all the categories in the database.
It retuns a slice of uint with category id and an error object.
func (*Authority) GetCategoryPermissions ¶
func (a *Authority) GetCategoryPermissions() ([]domain.CategoryPermissionsResponse, error)
GetCategoryPermissions retrieves the permissions associated with all the categories in the database.
It returns a slice of domain.CategoryPermissionsResponse and an error object.
func (*Authority) GetPermissions ¶
func (a *Authority) GetPermissions() ([]models.Permission, error)
GetPermissions retrieves all the permissions in the database.
It retuns a slice of string with permission names and an error object.
func (*Authority) GetPermissionsByCategory ¶
func (a *Authority) GetPermissionsByCategory(categoryID uint) ([]models.Permission, error)
GetPermissionsByCategory retrieves the list of permissions associated with a category.
It takes an uint parameter, categoryID. It returns a slice of permission objects associated with the category and an error object.
func (*Authority) GetRoles ¶
GetRoles retrieves all the roles in the database.
It retuns a slice of role objects and an error object.
func (*Authority) GetUserRoles ¶
GetUserRoles retrieves all the roles assigned to a user.
It takes in an uint, userID and returns a slice of role objects and an error object.
func (*Authority) GetUserRolesUUID ¶
GetUserRolesUUID retrieves all the roles assigned to a user.
It takes in an uuid.UUID, userID and returns a slice of role objects and an error object.
func (*Authority) RevokePermission ¶
RevokePermission revokes a permission from the user.
It takes in two parameters: userID of type uint and permName of type string and returns an error object.
func (*Authority) RevokePermissionUUID ¶
RevokePermissionUUID revokes a permission from the user.
It takes in two parameters: userID of type uuid.UUID and permName of type string and returns an error object.
func (*Authority) RevokeRole ¶
RevokeRole revokes a role from the user.
It takes in two uint parameters: userID and roleID and returns an error object.
func (*Authority) RevokeRolePermission ¶
RevokeRolePermission revokes a permission from a role.
It takes in two uint parameters: roleID and permissionID and returns an error object.
func (*Authority) RevokeRoleUUID ¶
RevokeRole revokes a role from the user.
It takes in two parameters: userID of type uuid.UUID and roleID of type uint and returns an error object.
func (*Authority) UpdateCategory ¶
UpdateCategory updates a category of the given category id with specified category name.
It takes in two parameters: categoryID of type uint and categoryName of type string and returns an error object.