| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package locale
- import (
- "yunion.io/x/pkg/util/rbacscope"
- )
- const (
- RoleAdmin = "admin"
- RoleFA = "fa"
- RoleDomainFA = "domainfa"
- RoleProjectFA = "projectfa"
- RoleSA = "sa"
- RoleProjectOwner = "project_owner"
- RoleDomainAdmin = "domainadmin"
- RoleDomainEditor = "domain_editor"
- RoleDomainViewer = "domain_viewer"
- RoleProjectEditor = "project_editor"
- RoleProjectViewer = "project_viewer"
- RoleMember = "member"
- )
- type sPolicyDefinition struct {
- Name string
- DescCN string
- Desc string
- Scope rbacscope.TRbacScope
- Services map[string][]string
- Extra map[string]map[string][]string
- AvailableRoles []string
- }
- type SRoleDefiniton struct {
- Name string
- Description string
- Policies []string
- Project string
- IsPublic bool
- DescriptionCN string
- }
- var (
- policyDefinitons = []sPolicyDefinition{
- {
- Name: "",
- DescCN: "任意资源",
- Desc: "any resources",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "*": nil,
- },
- },
- {
- Name: "dashboard",
- DescCN: "控制面板查看相关资源",
- Desc: "resources for viewing dashboard",
- Scope: rbacscope.ScopeProject,
- Extra: map[string]map[string][]string{
- "compute": {
- "dashboard": {
- "get",
- },
- "capabilities": {
- "list",
- },
- "usages": {
- "list",
- "get",
- },
- "quotas": {
- "list",
- "get",
- },
- "zone_quotas": {
- "list",
- "get",
- },
- "region_quotas": {
- "list",
- "get",
- },
- "project_quotas": {
- "list",
- "get",
- },
- "domain_quotas": {
- "list",
- "get",
- },
- "infras_quotas": {
- "list",
- "get",
- },
- },
- "image": {
- "usages": {
- "list",
- "get",
- },
- "image_quotas": {
- "list",
- "get",
- },
- },
- "identity": {
- "usages": {
- "list",
- "get",
- },
- "identity_quotas": {
- "list",
- "get",
- },
- "projects": {
- "list",
- },
- },
- "meter": {
- "bill_conditions": {
- "list",
- },
- },
- "monitor": {
- "alertrecords": {
- "list",
- },
- "alertresources": {
- "list",
- },
- "unifiedmonitors": {
- "perform",
- },
- "monitorresourcealerts": {
- "list",
- "get",
- },
- "nodealerts": {
- "list",
- },
- },
- "notify": {
- "notifications": {
- "list",
- "get",
- },
- "robots": {
- "list",
- "get",
- },
- "receivers": {
- "list",
- "get",
- },
- },
- "devtool": {
- "scriptapplyrecords": {
- "list",
- "get",
- },
- },
- "yunionconf": {
- "scopedpolicybindings": {
- "list",
- "get",
- },
- },
- "suggestion": {
- "suggestsysalerts": {
- "list",
- "get",
- },
- },
- },
- },
- {
- Name: "compute",
- DescCN: "计算服务(云主机与容器)相关资源",
- Desc: "resources of computing (cloud servers and containers)",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "compute": nil,
- "image": nil,
- "k8s": nil,
- },
- },
- {
- Name: "server",
- DescCN: "云主机相关资源",
- Desc: "resources of cloud servers",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "compute": {
- "servers",
- "servertemplates",
- "instancegroups",
- "scalinggroups",
- "scalingactivities",
- "scalingpolicies",
- "disks",
- "networks",
- "eips",
- "snapshotpolicies",
- "snapshotpolicycaches",
- "snapshotpolicydisks",
- "snapshots",
- "instance_snapshots",
- "snapshotpolicies",
- "secgroupcaches",
- "secgrouprules",
- "secgroups",
- },
- "image": nil,
- },
- Extra: map[string]map[string][]string{
- "compute": {
- "isolated_devices": {
- "get",
- "list",
- },
- },
- },
- },
- {
- Name: "host",
- DescCN: "宿主机和物理机相关资源",
- Desc: "resources of hosts and baremetals",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "hosts",
- "isolated_devices",
- "hostwires",
- "hoststorages",
- "baremetalagents",
- "baremetalnetworks",
- "baremetalevents",
- },
- },
- },
- {
- Name: "storage",
- DescCN: "云硬盘存储相关资源",
- Desc: "resources of cloud disk storages",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "storages",
- },
- },
- },
- {
- Name: "loadbalancer",
- DescCN: "负载均衡相关资源",
- Desc: "resources of load balancers",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "compute": {
- "loadbalanceracls",
- "loadbalanceragents",
- "loadbalancerbackendgroups",
- "loadbalancerbackends",
- "loadbalancercertificates",
- "loadbalancerclusters",
- "loadbalancerlistenerrules",
- "loadbalancerlisteners",
- "loadbalancernetworks",
- "loadbalancers",
- },
- },
- Extra: map[string]map[string][]string{
- "compute": {
- "networks": {
- "get",
- "list",
- },
- },
- },
- },
- {
- Name: "oss",
- DescCN: "对象存储相关资源",
- Desc: "resources of object storages",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "compute": {
- "buckets",
- },
- },
- },
- {
- Name: "dbinstance",
- DescCN: "关系型数据库(MySQL等)相关资源",
- Desc: "resources of RDS",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "compute": {
- "dbinstance_skus",
- "dbinstanceaccounts",
- "dbinstancebackups",
- "dbinstancedatabases",
- "dbinstancenetworks",
- "dbinstanceparameters",
- "dbinstanceprivileges",
- "dbinstances",
- },
- },
- },
- {
- Name: "elasticcache",
- DescCN: "弹性缓存(Redis等)相关资源",
- Desc: "resources of elastic caches",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "compute": {
- "elasticcacheaccounts",
- "elasticcacheacls",
- "elasticcachebackups",
- "elasticcacheparameters",
- "elasticcaches",
- "elasticcacheskus",
- },
- },
- },
- {
- Name: "network",
- DescCN: "网络相关资源",
- Desc: "resources of networking",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "vpcs",
- "wires",
- "natdentries",
- "natgateways",
- "natsentries",
- "networkinterfacenetworks",
- "networkinterfaces",
- "networks",
- "reservedips",
- "route_tables",
- "globalvpcs",
- "vpc_peering_connections",
- "eips",
- "dns_recordsets",
- "dns_trafficpolicies",
- "dns_zonecaches",
- "dns_zones",
- "dnsrecords",
- },
- },
- },
- {
- Name: "snapshotpolicy",
- DescCN: "快照策略",
- Desc: "snapshot policy",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "snapshotpolicies",
- "snapshotpolicydisks",
- },
- },
- },
- {
- Name: "secgroup",
- DescCN: "安全组",
- Desc: "security group",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "secgroups",
- "secgrouprules",
- },
- },
- },
- {
- Name: "meter",
- DescCN: "计费计量分析服务相关资源",
- Desc: "resources of metering and billing service",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "meter": nil,
- "suggestion": nil,
- "notify": {
- "receivers",
- },
- },
- },
- {
- Name: "identity",
- DescCN: "身份认证(IAM)服务相关资源",
- Desc: "resources of identity service",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "identity": nil,
- },
- },
- {
- Name: "image",
- DescCN: "镜像服务相关资源",
- Desc: "resources of image service",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "image": nil,
- },
- },
- {
- Name: "monitor",
- DescCN: "监控服务相关资源",
- Desc: "resources of monitor service",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "monitor": nil,
- },
- },
- {
- Name: "container",
- DescCN: "容器服务相关资源",
- Desc: "resources of container service",
- Scope: rbacscope.ScopeProject,
- Services: map[string][]string{
- "k8s": nil,
- },
- },
- {
- Name: "cloudid",
- DescCN: "云用户及权限管理相关资源",
- Desc: "resources of service CloudId and IAM",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "cloudaccounts",
- "cloudproviders",
- },
- "identity": {
- "users",
- "projects",
- "roles",
- },
- "cloudid": nil,
- },
- },
- {
- Name: "cloudaccount",
- DescCN: "云账号管理相关资源",
- Desc: "resources for cloud account administration",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "cloudaccounts",
- "cloudproviderquotas",
- "cloudproviderregions",
- "cloudproviders",
- },
- },
- },
- {
- Name: "projectresource",
- DescCN: "项目管理相关资源",
- Desc: "resources for project administration",
- Scope: rbacscope.ScopeDomain,
- Services: map[string][]string{
- "compute": {
- "project_quotas",
- "quotas",
- "region_quotas",
- "zone_quotas",
- },
- "image": {
- "image_quotas",
- },
- "identity": {
- "projects",
- "roles",
- "policies",
- },
- },
- },
- {
- Name: "domainresource",
- DescCN: "域管理相关资源",
- Desc: "resources for domain administration",
- Scope: rbacscope.ScopeSystem,
- Services: map[string][]string{
- "compute": {
- "domain_quotas",
- "infras_quotas",
- },
- "identity": {
- "domains",
- "identity_quotas",
- "projects",
- "roles",
- "policies",
- "users",
- "groups",
- },
- },
- },
- {
- Name: "notify",
- DescCN: "通知服务相关资源",
- Desc: "resources of notify service",
- Scope: rbacscope.ScopeSystem,
- Services: map[string][]string{
- "notify": nil,
- },
- },
- {
- Name: "log",
- DescCN: "日志服务相关资源",
- Desc: "resources of logger service",
- Scope: rbacscope.ScopeSystem,
- Services: map[string][]string{
- "log": nil,
- },
- AvailableRoles: []string{
- "viewer",
- },
- },
- }
- adminPerformActions = map[string]map[string][]string{
- "compute": map[string][]string{
- "servers": []string{
- "snapshot-and-clone",
- "createdisk",
- "create-eip",
- "create-backup",
- "save-image",
- "delete-disk",
- "delete-eip",
- "delete-backup",
- },
- "buckets": []string{
- "upload",
- "delete",
- },
- },
- "k8s": map[string][]string{
- "kubeclusters": []string{
- "add-machines",
- "delete-machines",
- },
- },
- }
- RoleDefinitions = []SRoleDefiniton{
- {
- Name: RoleAdmin,
- DescriptionCN: "系统管理员",
- Description: "System administrator",
- Policies: []string{
- "sysadmin",
- },
- Project: "system",
- IsPublic: false,
- },
- {
- Name: RoleDomainAdmin,
- DescriptionCN: "域管理员",
- Description: "Domain administrator",
- Policies: []string{
- "domain-admin",
- },
- IsPublic: true,
- },
- {
- Name: RoleProjectOwner,
- DescriptionCN: "项目主管",
- Description: "Project owner",
- Policies: []string{
- "project-admin",
- },
- IsPublic: true,
- },
- {
- Name: RoleFA,
- DescriptionCN: "系统财务管理员",
- Description: "System finance administrator",
- Policies: []string{
- "sys-meter-admin",
- "sys-dashboard",
- },
- IsPublic: false,
- },
- {
- Name: RoleDomainFA,
- DescriptionCN: "域财务管理员",
- Description: "Domain finance administrator",
- Policies: []string{
- "domain-meter-admin",
- "domain-dashboard",
- },
- IsPublic: true,
- },
- {
- Name: RoleProjectFA,
- DescriptionCN: "项目财务管理员",
- Description: "Project finance administrator",
- Policies: []string{
- "project-meter-admin",
- "project-dashboard",
- },
- IsPublic: true,
- },
- {
- Name: RoleDomainEditor,
- DescriptionCN: "域操作员",
- Description: "Domain operation administrator",
- Policies: []string{
- "domain-editor",
- "domain-dashboard",
- },
- IsPublic: true,
- },
- {
- Name: RoleProjectEditor,
- DescriptionCN: "项目操作员",
- Description: "Project operator",
- Policies: []string{
- "project-editor",
- "project-dashboard",
- },
- IsPublic: true,
- },
- {
- Name: RoleDomainViewer,
- DescriptionCN: "域只读管理员",
- Description: "Domain read-only administrator",
- Policies: []string{
- "domain-viewer",
- "domain-dashboard",
- },
- IsPublic: true,
- },
- {
- Name: RoleProjectViewer,
- DescriptionCN: "项目只读成员",
- Description: "Project read-only member",
- Policies: []string{
- "project-viewer",
- "project-dashboard",
- },
- IsPublic: true,
- },
- {
- Name: "sys_opsadmin",
- DescriptionCN: "全局系统管理员",
- Description: "System-wide operation manager",
- Policies: []string{
- "sys-opsadmin",
- },
- IsPublic: true,
- },
- {
- Name: "sys_secadmin",
- DescriptionCN: "全局安全管理员",
- Description: "System-wide security manager",
- Policies: []string{
- "sys-secadmin",
- },
- IsPublic: true,
- },
- {
- Name: "sys_adtadmin",
- DescriptionCN: "全局审计管理员",
- Description: "System-wide audit manager",
- Policies: []string{
- "sys-adtadmin",
- },
- IsPublic: true,
- },
- {
- Name: "domain_opsadmin",
- DescriptionCN: "组织系统管理员",
- Description: "Domain-wide operation manager",
- Policies: []string{
- "domain-opsadmin",
- },
- IsPublic: true,
- },
- {
- Name: "domain_secadmin",
- DescriptionCN: "组织安全管理员",
- Description: "Domain-wide security manager",
- Policies: []string{
- "domain-secadmin",
- },
- IsPublic: true,
- },
- {
- Name: "domain_adtadmin",
- DescriptionCN: "组织审计管理员",
- Description: "Domain-wide audit manager",
- Policies: []string{
- "domain-adtadmin",
- },
- IsPublic: true,
- },
- {
- Name: "normal_user",
- DescriptionCN: "缺省普通用户角色",
- Description: "Default normal user role",
- Policies: []string{
- "normal-user",
- },
- IsPublic: true,
- },
- }
- )
|