2022-02-17 12:13:31 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
|
|
|
|
|
|
class Scope(models.TextChoices):
|
|
|
|
system = 'system', _('System')
|
|
|
|
org = 'org', _('Organization')
|
|
|
|
|
|
|
|
|
|
|
|
exclude_permissions = (
|
|
|
|
# ('App', 'Model', 'Action', 'Resource') Model 和 Resource 可能不同
|
|
|
|
# users.add_user
|
|
|
|
('auth', '*', '*', '*'),
|
|
|
|
('captcha', '*', '*', '*'),
|
|
|
|
('contenttypes', '*', '*', '*'),
|
|
|
|
('django_cas_ng', '*', '*', '*'),
|
|
|
|
('django_celery_beat', '*', '*', '*'),
|
2022-03-02 12:48:43 +00:00
|
|
|
('jms_oidc_rp', '*', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('admin', '*', '*', '*'),
|
|
|
|
('sessions', '*', '*', '*'),
|
|
|
|
('notifications', '*', '*', '*'),
|
2022-03-04 02:16:21 +00:00
|
|
|
('common', 'setting', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
|
2022-03-07 11:02:37 +00:00
|
|
|
('authentication', 'privatetoken', '*', '*'),
|
2022-03-11 05:30:14 +00:00
|
|
|
('authentication', 'connectiontoken', 'change,delete', 'connectiontoken'),
|
2022-03-16 08:26:59 +00:00
|
|
|
('authentication', 'ssotoken', '*', '*'),
|
2022-03-11 05:30:14 +00:00
|
|
|
('authentication', 'superconnectiontoken', 'change,delete', 'superconnectiontoken'),
|
2022-04-19 11:10:36 +00:00
|
|
|
('authentication', 'temptoken', 'delete', 'temptoken'),
|
2022-03-07 11:02:37 +00:00
|
|
|
('users', 'userpasswordhistory', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('assets', 'adminuser', '*', '*'),
|
|
|
|
('assets', 'assetgroup', '*', '*'),
|
|
|
|
('assets', 'cluster', '*', '*'),
|
|
|
|
('assets', 'favoriteasset', '*', '*'),
|
2022-09-19 09:00:03 +00:00
|
|
|
('assets', 'historicalaccount', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('assets', 'assetuser', '*', '*'),
|
2022-03-14 03:25:45 +00:00
|
|
|
('assets', 'gathereduser', 'add,delete,change', 'gathereduser'),
|
2022-03-14 06:23:13 +00:00
|
|
|
('assets', 'accountbackupplanexecution', 'delete,change', 'accountbackupplanexecution'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('assets', 'gathereduser', 'add,delete,change', 'gathereduser'),
|
2022-12-23 11:01:29 +00:00
|
|
|
('assets', 'web', '*', '*'),
|
|
|
|
('assets', 'host', '*', '*'),
|
|
|
|
('assets', 'cloud', '*', '*'),
|
|
|
|
('assets', 'device', '*', '*'),
|
|
|
|
('assets', 'database', '*', '*'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('assets', 'protocol', '*', '*'),
|
|
|
|
('assets', 'systemuser', '*', '*'),
|
|
|
|
('assets', 'baseautomation', '*', '*'),
|
|
|
|
('assets', 'pingautomation', '*', '*'),
|
|
|
|
('assets', 'platformprotocol', '*', '*'),
|
|
|
|
('assets', 'platformautomation', '*', '*'),
|
|
|
|
('assets', 'gatherfactsautomation', '*', '*'),
|
|
|
|
('assets', 'pushaccountautomation', '*', '*'),
|
|
|
|
('assets', 'verifyaccountautomation', '*', '*'),
|
|
|
|
('assets', 'changesecretrecord', 'add,delete,change', 'changesecretrecord'),
|
|
|
|
('assets', 'automationexecution', '*', 'automationexecution'),
|
2022-07-14 07:37:00 +00:00
|
|
|
# TODO 暂时去掉历史账号的权限
|
2022-09-19 09:00:03 +00:00
|
|
|
('assets', 'account', '*', 'assethistoryaccount'),
|
|
|
|
('assets', 'account', '*', 'assethistoryaccountsecret'),
|
2022-07-14 07:37:00 +00:00
|
|
|
|
2022-02-17 12:13:31 +00:00
|
|
|
('perms', 'userassetgrantedtreenoderelation', '*', '*'),
|
|
|
|
('perms', 'usergrantedmappingnode', '*', '*'),
|
|
|
|
('perms', 'permnode', '*', '*'),
|
|
|
|
('perms', 'rebuildusertreetask', '*', '*'),
|
2022-03-07 11:02:37 +00:00
|
|
|
('perms', 'permedasset', 'add,change,delete', 'permedasset'),
|
|
|
|
('perms', 'permedapplication', 'add,change,delete', 'permedapplication'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('rbac', 'contenttype', '*', '*'),
|
|
|
|
('rbac', 'permission', 'add,delete,change', 'permission'),
|
2022-03-07 06:38:09 +00:00
|
|
|
('rbac', 'rolebinding', '*', '*'),
|
2022-03-18 07:04:13 +00:00
|
|
|
('rbac', 'systemrolebinding', 'change', 'systemrolebinding'),
|
|
|
|
('rbac', 'orgrolebinding', 'change', 'orgrolebinding'),
|
2022-03-04 02:16:21 +00:00
|
|
|
('rbac', 'role', '*', '*'),
|
2022-03-14 11:54:06 +00:00
|
|
|
('ops', 'adhoc', 'delete,change', '*'),
|
2022-03-16 11:25:06 +00:00
|
|
|
('ops', 'adhocexecution', 'add,delete,change', '*'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('ops', 'jobexecution', 'change,delete', 'jobexecution'),
|
|
|
|
('ops', 'historicaljob', '*', '*'),
|
|
|
|
('ops', 'celerytask', 'add,change,delete', 'celerytask'),
|
|
|
|
('ops', 'celerytaskexecution', 'add,change,delete', 'celerytaskexecution'),
|
2022-03-07 11:02:37 +00:00
|
|
|
('ops', 'commandexecution', 'delete,change', 'commandexecution'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('orgs', 'organizationmember', '*', '*'),
|
2022-03-15 12:23:22 +00:00
|
|
|
('settings', 'setting', 'add,change,delete', 'setting'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('audits', 'operatelog', 'add,delete,change', 'operatelog'),
|
|
|
|
('audits', 'passwordchangelog', 'add,change,delete', 'passwordchangelog'),
|
2022-03-08 09:21:53 +00:00
|
|
|
('audits', 'userloginlog', 'add,change,delete,change', 'userloginlog'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('audits', 'ftplog', 'change,delete', 'ftplog'),
|
2022-03-11 09:24:28 +00:00
|
|
|
('tickets', 'ticketassignee', '*', 'ticketassignee'),
|
2022-03-11 03:04:21 +00:00
|
|
|
('tickets', 'ticketflow', 'add,delete', 'ticketflow'),
|
2022-03-16 06:43:20 +00:00
|
|
|
('tickets', 'comment', '*', '*'),
|
|
|
|
('tickets', 'ticket', 'add,delete,change', 'ticket'),
|
2022-03-10 07:52:08 +00:00
|
|
|
('tickets', 'ticketstep', '*', '*'),
|
2022-03-11 03:04:21 +00:00
|
|
|
('tickets', 'approvalrule', '*', '*'),
|
2022-06-30 03:17:12 +00:00
|
|
|
('tickets', 'applyloginticket', '*', '*'),
|
|
|
|
('tickets', 'applyloginassetticket', '*', '*'),
|
|
|
|
('tickets', 'applycommandticket', '*', '*'),
|
|
|
|
('tickets', 'applyassetticket', '*', '*'),
|
|
|
|
('tickets', 'applyapplicationticket', '*', '*'),
|
2022-03-11 09:24:28 +00:00
|
|
|
('tickets', 'superticket', 'delete', 'superticket'),
|
2022-03-16 06:43:20 +00:00
|
|
|
('tickets', 'ticketsession', 'view,delete', 'ticketsession'),
|
2022-03-02 12:48:43 +00:00
|
|
|
('xpack', 'interface', '*', '*'),
|
|
|
|
('xpack', 'license', '*', '*'),
|
2022-03-10 10:11:33 +00:00
|
|
|
('xpack', 'syncinstancedetail', 'add,delete,change', 'syncinstancedetail'),
|
2022-03-15 06:09:14 +00:00
|
|
|
('xpack', 'syncinstancetaskexecution', 'delete,change', 'syncinstancetaskexecution'),
|
2022-03-02 12:48:43 +00:00
|
|
|
('common', 'permission', 'add,delete,view,change', 'permission'),
|
|
|
|
('terminal', 'command', 'delete,change', 'command'),
|
2022-03-08 09:21:53 +00:00
|
|
|
('terminal', 'status', 'delete,change', 'status'),
|
2022-03-17 03:19:16 +00:00
|
|
|
('terminal', 'task', 'add,delete', 'task'),
|
2022-03-02 12:48:43 +00:00
|
|
|
('terminal', 'sessionjoinrecord', 'delete', 'sessionjoinrecord'),
|
2022-03-15 03:33:38 +00:00
|
|
|
('terminal', 'sessionreplay', 'add,change,delete', 'sessionreplay'),
|
2022-03-15 04:56:10 +00:00
|
|
|
('terminal', 'sessionsharing', 'view,add,change,delete', 'sessionsharing'),
|
2022-03-15 05:11:47 +00:00
|
|
|
('terminal', 'session', 'delete,share', 'session'),
|
2022-03-07 11:02:37 +00:00
|
|
|
('terminal', 'session', 'delete,change', 'command'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('terminal', 'appletpublication', '*', '*'),
|
|
|
|
('terminal', 'applethostdeployment', '*', '*'),
|
2022-12-21 12:19:13 +00:00
|
|
|
('applications', '*', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
only_system_permissions = (
|
2022-04-27 09:16:30 +00:00
|
|
|
('assets', 'platform', 'add,change,delete', 'platform'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('users', 'user', 'delete', 'user'),
|
|
|
|
('rbac', 'role', 'delete,add,change', 'role'),
|
|
|
|
('rbac', 'systemrole', '*', '*'),
|
|
|
|
('rbac', 'rolebinding', '*', '*'),
|
|
|
|
('rbac', 'systemrolebinding', '*', '*'),
|
2022-03-08 12:22:10 +00:00
|
|
|
('rbac', 'orgrole', 'delete,add,change', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('orgs', 'organization', '*', '*'),
|
|
|
|
('xpack', 'license', '*', '*'),
|
|
|
|
('settings', 'setting', '*', '*'),
|
2022-03-18 09:32:31 +00:00
|
|
|
('tickets', '*', '*', '*'),
|
2022-03-07 06:38:09 +00:00
|
|
|
('ops', 'task', 'view', 'taskmonitor'),
|
2022-03-04 02:16:21 +00:00
|
|
|
('terminal', 'terminal', '*', '*'),
|
2022-03-07 03:19:03 +00:00
|
|
|
('terminal', 'commandstorage', '*', '*'),
|
|
|
|
('terminal', 'replaystorage', '*', '*'),
|
|
|
|
('terminal', 'status', '*', '*'),
|
|
|
|
('terminal', 'task', '*', '*'),
|
2022-04-20 10:50:53 +00:00
|
|
|
('terminal', 'endpoint', '*', '*'),
|
|
|
|
('terminal', 'endpointrule', '*', '*'),
|
2022-03-16 04:01:51 +00:00
|
|
|
('authentication', '*', '*', '*'),
|
2022-03-18 09:44:20 +00:00
|
|
|
('tickets', '*', '*', '*'),
|
2022-04-20 10:50:53 +00:00
|
|
|
('orgs', 'organization', 'view', 'rootorg'),
|
2022-02-17 12:13:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
only_org_permissions = (
|
|
|
|
)
|
|
|
|
|
|
|
|
system_exclude_permissions = list(exclude_permissions) + list(only_org_permissions)
|
|
|
|
org_exclude_permissions = list(exclude_permissions) + list(only_system_permissions)
|