Documentation ¶
Index ¶
- Constants
- Variables
- func AddPermsToList(perms []*Perm)
- func BuildGuard(category Category, name Name) string
- func BuildGuardWithKey(category Category, name Name, key Key) string
- type AddPerm
- type Attr
- type Category
- type JobAttrUpdateEvent
- type JobGradeList
- type JobList
- type JobPermission
- type Key
- type Name
- type Params
- type Perm
- type Permissions
- type Perms
- func (p *Perms) AddOrUpdateAttributesToRole(ctx context.Context, job string, roleId uint64, ...) error
- func (p *Perms) ApplyJobPermissions(ctx context.Context, job string) error
- func (p *Perms) Attr(userInfo *userinfo.UserInfo, category Category, name Name, key Key) (any, error)
- func (p *Perms) Can(userInfo *userinfo.UserInfo, category Category, name Name) bool
- func (p *Perms) ClearJobAttributes(ctx context.Context, job string) error
- func (p *Perms) CountRolesForJob(ctx context.Context, job string) (int64, error)
- func (p *Perms) CreateAttribute(ctx context.Context, permId uint64, key Key, aType permissions.AttributeTypes, ...) (uint64, error)
- func (p *Perms) CreatePermission(ctx context.Context, category Category, name Name) (uint64, error)
- func (p *Perms) CreateRole(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error)
- func (p *Perms) DeleteRole(ctx context.Context, id uint64) error
- func (p *Perms) FlattenRoleAttributes(job string, grade int32) ([]string, error)
- func (p *Perms) GetAllAttributes(ctx context.Context, job string, grade int32) ([]*permissions.RoleAttribute, error)
- func (p *Perms) GetAllPermissions(ctx context.Context) ([]*permissions.Permission, error)
- func (p *Perms) GetAttribute(category Category, name Name, key Key) (*permissions.RoleAttribute, error)
- func (p *Perms) GetAttributeByIDs(ctx context.Context, attrIds ...uint64) ([]*permissions.RoleAttribute, error)
- func (p *Perms) GetClosestJobRole(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error)
- func (p *Perms) GetJobAttrMaxVals(job string, attrId uint64) (*permissions.AttributeValues, bool)
- func (p *Perms) GetJobPermissions(ctx context.Context, job string) ([]*permissions.Permission, error)
- func (p *Perms) GetJobRoles(ctx context.Context, job string) (collections.Roles, error)
- func (p *Perms) GetJobRolesUpTo(ctx context.Context, job string, grade int32) (collections.Roles, error)
- func (p *Perms) GetPermission(ctx context.Context, category Category, name Name) (*permissions.Permission, error)
- func (p *Perms) GetPermissionsByIDs(ctx context.Context, ids ...uint64) ([]*permissions.Permission, error)
- func (p *Perms) GetPermissionsOfUser(userInfo *userinfo.UserInfo) (collections.Permissions, error)
- func (p *Perms) GetRole(ctx context.Context, id uint64) (*model.FivenetRoles, error)
- func (p *Perms) GetRoleAttributeByID(roleId uint64, attrId uint64) (*permissions.RoleAttribute, bool)
- func (p *Perms) GetRoleAttributes(job string, grade int32) ([]*permissions.RoleAttribute, error)
- func (p *Perms) GetRoleByJobAndGrade(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error)
- func (p *Perms) GetRolePermissions(ctx context.Context, id uint64) ([]*permissions.Permission, error)
- func (p *Perms) GetRoles(ctx context.Context, excludeSystem bool) (collections.Roles, error)
- func (p *Perms) LookupAttributeByID(id uint64) (*cacheAttr, bool)
- func (p *Perms) RemoveAttributesFromRole(ctx context.Context, roleId uint64, attrs ...*permissions.RoleAttribute) error
- func (p *Perms) RemovePermissionsByIDs(ctx context.Context, ids ...uint64) error
- func (p *Perms) RemovePermissionsFromRole(ctx context.Context, roleId uint64, perms ...uint64) error
- func (p *Perms) SetDefaultRolePerms(ctx context.Context, defaultPerms []string) error
- func (p *Perms) UpdateAttribute(ctx context.Context, attrId uint64, permId uint64, key Key, ...) error
- func (p *Perms) UpdateJobAttributeMaxValues(ctx context.Context, job string, attrId uint64, ...) error
- func (p *Perms) UpdateJobPermissions(ctx context.Context, job string, id uint64, val bool) error
- func (p *Perms) UpdatePermission(ctx context.Context, id uint64, category Category, name Name) error
- func (p *Perms) UpdateRolePermissions(ctx context.Context, roleId uint64, perms ...AddPerm) error
- type RoleIDEvent
- type StringList
Constants ¶
View Source
const ( BaseSubject events.Subject = "perms" RoleCreatedSubject events.Type = "roleperm.create" RolePermUpdateSubject events.Type = "roleperm.update" RoleDeletedSubject events.Type = "roleperm.delete" RoleAttrUpdateSubject events.Type = "roleattr.update" JobAttrUpdateSubject events.Type = "jobattr.update" )
View Source
const ( DefaultRoleJob = "__default__" DefaultRoleJobGrade = int32(1) )
Variables ¶
View Source
var ErrAttrInvalid = errors.New("invalid attributes")
Functions ¶
func AddPermsToList ¶
func AddPermsToList(perms []*Perm)
func BuildGuard ¶
Types ¶
type Attr ¶
type Attr struct { ID uint64 Key Key Type permissions.AttributeTypes ValidValues any DefaultValues any }
type JobAttrUpdateEvent ¶
type JobAttrUpdateEvent struct {
Job string
}
type JobGradeList ¶
type JobPermission ¶
type Permissions ¶
type Permissions interface { GetAllPermissions(ctx context.Context) ([]*permissions.Permission, error) GetPermissionsByIDs(ctx context.Context, ids ...uint64) ([]*permissions.Permission, error) GetPermission(ctx context.Context, category Category, name Name) (*permissions.Permission, error) CreatePermission(ctx context.Context, category Category, name Name) (uint64, error) GetPermissionsOfUser(userInfo *userinfo.UserInfo) (collections.Permissions, error) GetRoles(ctx context.Context, excludeSystem bool) (collections.Roles, error) GetJobRoles(ctx context.Context, job string) (collections.Roles, error) GetJobRolesUpTo(ctx context.Context, job string, grade int32) (collections.Roles, error) GetClosestJobRole(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error) CountRolesForJob(ctx context.Context, prefix string) (int64, error) GetRole(ctx context.Context, id uint64) (*model.FivenetRoles, error) GetRoleByJobAndGrade(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error) GetRolePermissions(ctx context.Context, id uint64) ([]*permissions.Permission, error) CreateRole(ctx context.Context, job string, grade int32) (*model.FivenetRoles, error) DeleteRole(ctx context.Context, id uint64) error UpdateRolePermissions(ctx context.Context, id uint64, perms ...AddPerm) error RemovePermissionsFromRole(ctx context.Context, id uint64, perms ...uint64) error GetJobPermissions(ctx context.Context, job string) ([]*permissions.Permission, error) UpdateJobPermissions(ctx context.Context, job string, id uint64, val bool) error ApplyJobPermissions(ctx context.Context, job string) error Can(userInfo *userinfo.UserInfo, category Category, name Name) bool LookupAttributeByID(id uint64) (*cacheAttr, bool) GetAttribute(category Category, name Name, key Key) (*permissions.RoleAttribute, error) GetAttributeByIDs(ctx context.Context, ids ...uint64) ([]*permissions.RoleAttribute, error) CreateAttribute(ctx context.Context, permId uint64, key Key, aType permissions.AttributeTypes, validValues *permissions.AttributeValues) (uint64, error) UpdateAttribute(ctx context.Context, attributeId uint64, permId uint64, key Key, aType permissions.AttributeTypes, validValues *permissions.AttributeValues) error GetRoleAttributes(job string, grade int32) ([]*permissions.RoleAttribute, error) GetRoleAttributeByID(roleId uint64, attrId uint64) (*permissions.RoleAttribute, bool) FlattenRoleAttributes(job string, grade int32) ([]string, error) GetAllAttributes(ctx context.Context, job string, grade int32) ([]*permissions.RoleAttribute, error) AddOrUpdateAttributesToRole(ctx context.Context, job string, roleId uint64, attrs ...*permissions.RoleAttribute) error RemoveAttributesFromRole(ctx context.Context, roleId uint64, attrs ...*permissions.RoleAttribute) error GetJobAttrMaxVals(job string, attrId uint64) (*permissions.AttributeValues, bool) UpdateJobAttributeMaxValues(ctx context.Context, job string, attrId uint64, maxValues *permissions.AttributeValues) error ClearJobAttributes(ctx context.Context, job string) error Attr(userInfo *userinfo.UserInfo, category Category, name Name, key Key) (any, error) SetDefaultRolePerms(ctx context.Context, defaultPerms []string) error }
func New ¶
func New(p Params) (Permissions, error)
type Perms ¶
type Perms struct {
// contains filtered or unexported fields
}
func (*Perms) AddOrUpdateAttributesToRole ¶
func (p *Perms) AddOrUpdateAttributesToRole(ctx context.Context, job string, roleId uint64, attrs ...*permissions.RoleAttribute) error
func (*Perms) ApplyJobPermissions ¶
func (*Perms) ClearJobAttributes ¶ added in v0.9.2
func (*Perms) CountRolesForJob ¶
func (*Perms) CreateAttribute ¶
func (p *Perms) CreateAttribute(ctx context.Context, permId uint64, key Key, aType permissions.AttributeTypes, validValues *permissions.AttributeValues) (uint64, error)
func (*Perms) CreatePermission ¶
func (*Perms) CreateRole ¶
func (*Perms) FlattenRoleAttributes ¶
func (*Perms) GetAllAttributes ¶
func (p *Perms) GetAllAttributes(ctx context.Context, job string, grade int32) ([]*permissions.RoleAttribute, error)
func (*Perms) GetAllPermissions ¶
func (p *Perms) GetAllPermissions(ctx context.Context) ([]*permissions.Permission, error)
func (*Perms) GetAttribute ¶
func (p *Perms) GetAttribute(category Category, name Name, key Key) (*permissions.RoleAttribute, error)
func (*Perms) GetAttributeByIDs ¶
func (p *Perms) GetAttributeByIDs(ctx context.Context, attrIds ...uint64) ([]*permissions.RoleAttribute, error)
func (*Perms) GetClosestJobRole ¶
func (*Perms) GetJobAttrMaxVals ¶
func (p *Perms) GetJobAttrMaxVals(job string, attrId uint64) (*permissions.AttributeValues, bool)
func (*Perms) GetJobPermissions ¶
func (p *Perms) GetJobPermissions(ctx context.Context, job string) ([]*permissions.Permission, error)
func (*Perms) GetJobRoles ¶
func (*Perms) GetJobRolesUpTo ¶
func (*Perms) GetPermission ¶
func (p *Perms) GetPermission(ctx context.Context, category Category, name Name) (*permissions.Permission, error)
func (*Perms) GetPermissionsByIDs ¶
func (p *Perms) GetPermissionsByIDs(ctx context.Context, ids ...uint64) ([]*permissions.Permission, error)
func (*Perms) GetPermissionsOfUser ¶
func (p *Perms) GetPermissionsOfUser(userInfo *userinfo.UserInfo) (collections.Permissions, error)
func (*Perms) GetRoleAttributeByID ¶
func (p *Perms) GetRoleAttributeByID(roleId uint64, attrId uint64) (*permissions.RoleAttribute, bool)
func (*Perms) GetRoleAttributes ¶
func (p *Perms) GetRoleAttributes(job string, grade int32) ([]*permissions.RoleAttribute, error)
func (*Perms) GetRoleByJobAndGrade ¶
func (*Perms) GetRolePermissions ¶
func (p *Perms) GetRolePermissions(ctx context.Context, id uint64) ([]*permissions.Permission, error)
func (*Perms) LookupAttributeByID ¶
func (*Perms) RemoveAttributesFromRole ¶
func (p *Perms) RemoveAttributesFromRole(ctx context.Context, roleId uint64, attrs ...*permissions.RoleAttribute) error
func (*Perms) RemovePermissionsByIDs ¶
func (*Perms) RemovePermissionsFromRole ¶
func (*Perms) SetDefaultRolePerms ¶
func (*Perms) UpdateAttribute ¶
func (p *Perms) UpdateAttribute(ctx context.Context, attrId uint64, permId uint64, key Key, aType permissions.AttributeTypes, validValues *permissions.AttributeValues) error
func (*Perms) UpdateJobAttributeMaxValues ¶
func (p *Perms) UpdateJobAttributeMaxValues(ctx context.Context, job string, attrId uint64, maxValues *permissions.AttributeValues) error
func (*Perms) UpdateJobPermissions ¶
func (*Perms) UpdatePermission ¶
type RoleIDEvent ¶
type RoleIDEvent struct {
RoleID uint64
}
type StringList ¶
type StringList []string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.