Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIfRoleIsManager(role string) bool
- func GetScopeManagerRoleMap() map[apistructs.ScopeType]map[string]RoleInfo
- func Init(opts ...bundle.Option)
- func IsManager(userID string, scopeType apistructs.ScopeType, scopeID uint64) (bool, error)
- type RoleInfo
- type RolesSet
- func (p *RolesSet) Apps() map[string][]string
- func (p *RolesSet) OrgID() uint64
- func (p *RolesSet) Orgs() map[string][]string
- func (p *RolesSet) Projects() map[string][]string
- func (p *RolesSet) RolesApps(roles ...string) []string
- func (p *RolesSet) RolesOrgs(roles ...string) []string
- func (p *RolesSet) RolesProjects(roles ...string) []string
- func (p *RolesSet) UserID() string
Constants ¶
View Source
const ( // sys RoleSysManager = "Manager" // org RoleOrgManager = "Manager" RoleOrgDev = "Dev" RoleOrgOps = "Ops" RoleOrgSupport = "Support" RoleOrgDataManager = "DataManager" RoleOrgDataEngineer = "DataEngineer" RoleOrgReporter = "Reporter" RoleOrgEdgeAppEngineer = "EdgeOps" RoleOrgGuest = "Guest" // project RoleProjectOwner = "Owner" RoleProjectLead = "Lead" RoleProjectPM = "PM" RoleProjectPD = "PD" RoleProjectDev = "Dev" RoleProjectQA = "QA" RoleProjectReporter = "Reporter" RoleProjectGuest = "Guest" // app RoleAppOwner = "Owner" RoleAppLead = "Lead" RoleAppDev = "Dev" RoleAppQA = "QA" RoleAppOps = "Ops" RoleAppGuest = "Guest" // publisher RolePublisherManager = "PublisherManager" RolePublisherMember = "PublisherMember" // guest RoleGuest = "Guest" )
Variables ¶
View Source
var ( OrgMRoles = []string{"manager"} // 对企业有管理权限的角色列表 ProMRoles = []string{"owner", "lead", "pm"} // 对项目有管理权限的角色列表 AppMRoles = []string{"owner", "lead"} // 对应用有管理权限的角色列表 )
View Source
var AllScopeRoleMap = map[apistructs.ScopeType]map[string]RoleInfo{ apistructs.SysScope: { RoleSysManager: {Role: RoleSysManager, IsHide: false, I18nKey: "SysManagerRole", IsManager: true, Level: 0}, }, apistructs.OrgScope: { RoleOrgManager: {Role: RoleSysManager, IsHide: false, I18nKey: "OrgManagerRole", IsManager: true, Level: 0}, RoleOrgDev: {Role: RoleOrgDev, IsHide: false, I18nKey: "OrgDevRole", IsManager: false, Level: 1}, RoleOrgOps: {Role: RoleOrgOps, IsHide: false, I18nKey: "OrgOpsRole", IsManager: false, Level: 2}, RoleOrgDataManager: {Role: RoleOrgDataManager, IsHide: false, I18nKey: "OrgDataManagerRole", IsManager: false, Level: 3}, RoleOrgDataEngineer: {Role: RoleOrgDataEngineer, IsHide: false, I18nKey: "OrgDataEngineerRole", IsManager: false, Level: 4}, RoleOrgSupport: {Role: RoleOrgSupport, IsHide: true, I18nKey: "OrgSupportRole", IsManager: false, Level: 5}, RoleOrgReporter: {Role: RoleOrgReporter, IsHide: false, I18nKey: "OrgReporterRole", IsManager: false, Level: 6}, RolePublisherManager: {Role: RolePublisherManager, IsHide: false, I18nKey: "PublisherManagerRole", IsManager: false, Level: 7}, RoleOrgEdgeAppEngineer: {Role: RoleOrgEdgeAppEngineer, IsHide: false, I18nKey: "RoleOrgEdgeAppEngineer", IsManager: false, Level: 8}, RoleOrgGuest: {Role: RoleProjectGuest, IsHide: true, I18nKey: "OrgGuestRole", IsManager: false, Level: 9}, }, apistructs.ProjectScope: { RoleProjectOwner: {Role: RoleProjectOwner, IsHide: false, I18nKey: "ProjectOwnerRole", IsManager: true, Level: 0}, RoleProjectLead: {Role: RoleProjectLead, IsHide: false, I18nKey: "ProjectLeadRole", IsManager: true, Level: 1}, RoleProjectPM: {Role: RoleProjectPM, IsHide: false, I18nKey: "ProjectPMRole", IsManager: true, Level: 2}, RoleProjectPD: {Role: RoleProjectPD, IsHide: false, I18nKey: "ProjectPDRole", IsManager: false, Level: 3}, RoleProjectDev: {Role: RoleProjectDev, IsHide: false, I18nKey: "ProjectDevRole", IsManager: false, Level: 4}, RoleProjectQA: {Role: RoleProjectQA, IsHide: false, I18nKey: "ProjectQARole", IsManager: false, Level: 5}, RoleProjectReporter: {Role: RoleProjectReporter, IsHide: false, I18nKey: "ProjectReporterRole", IsManager: false, Level: 6}, RoleProjectGuest: {Role: RoleProjectGuest, IsHide: true, I18nKey: "ProjectGuestRole", IsManager: false, Level: 7}, }, apistructs.AppScope: { RoleAppOwner: {Role: RoleAppOwner, IsHide: false, I18nKey: "AppOwnerRole", IsManager: true, Level: 0}, RoleAppLead: {Role: RoleAppLead, IsHide: false, I18nKey: "AppLeadRole", IsManager: true, Level: 1}, RoleAppOps: {Role: RoleAppOps, IsHide: false, I18nKey: "AppOpsRole", IsManager: false, Level: 2}, RoleAppDev: {Role: RoleAppDev, IsHide: false, I18nKey: "AppDevRole", IsManager: false, Level: 3}, RoleAppQA: {Role: RoleAppQA, IsHide: false, I18nKey: "AppQARole", IsManager: false, Level: 4}, RoleAppGuest: {Role: RoleAppGuest, IsHide: true, I18nKey: "AppGuestRole", IsManager: false, Level: 5}, }, apistructs.PublisherScope: { RolePublisherManager: {Role: RolePublisherManager, IsHide: false, I18nKey: "PublisherManagerRole", IsManager: true, Level: 0}, RolePublisherMember: {Role: RolePublisherMember, IsHide: false, I18nKey: "PublisherMemberRole", IsManager: false, Level: 1}, }, }
View Source
var Bdl *bundle.Bundle
Functions ¶
func CheckIfRoleIsManager ¶
CheckIfRoleIsManager returns whether the role is a manger or not
func GetScopeManagerRoleMap ¶
func GetScopeManagerRoleMap() map[apistructs.ScopeType]map[string]RoleInfo
Types ¶
type RolesSet ¶
type RolesSet struct {
// contains filtered or unexported fields
}
func FetchAssetRolesSet ¶
FetchAssetRolesSet fetches the permissions about Asset
func (*RolesSet) RolesApps ¶
RolesApps returns the list of applications IDs in which the user plays the roles 传入角色, 返回 app id 列表 (由于返回结果不会太多, 所以都没有做去重)
func (*RolesSet) RolesOrgs ¶
RolesOrgs returns the list of organizations IDs in which the user plays the roles
func (*RolesSet) RolesProjects ¶
RolesProjects returns the list of project IDs in which the user plays the roles
Click to show internal directories.
Click to hide internal directories.