2022-02-17 12:13:31 +00:00
|
|
|
from django.db import models
|
2023-07-24 03:52:25 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2022-02-17 12:13:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
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', '*', '*'),
|
2023-07-13 08:00:24 +00:00
|
|
|
('authentication', 'connectiontoken', 'delete,change', 'connectiontoken'),
|
|
|
|
('authentication', 'connectiontoken', 'view', 'connectiontokensecret'),
|
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', '*', '*'),
|
2023-12-21 07:00:46 +00:00
|
|
|
('users', 'usersession', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('assets', 'adminuser', '*', '*'),
|
2023-12-28 07:17:10 +00:00
|
|
|
('assets', 'label', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('assets', 'assetgroup', '*', '*'),
|
|
|
|
('assets', 'cluster', '*', '*'),
|
2023-01-16 11:02:09 +00:00
|
|
|
('assets', 'systemuser', '*', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('assets', 'favoriteasset', '*', '*'),
|
|
|
|
('assets', 'assetuser', '*', '*'),
|
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', 'baseautomation', '*', '*'),
|
2023-01-16 11:02:09 +00:00
|
|
|
('assets', 'assetbaseautomation', '*', '*'),
|
|
|
|
('assets', 'automationexecution', '*', '*'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('assets', 'pingautomation', '*', '*'),
|
|
|
|
('assets', 'platformprotocol', '*', '*'),
|
|
|
|
('assets', 'platformautomation', '*', '*'),
|
|
|
|
('assets', 'verifyaccountautomation', '*', '*'),
|
2023-01-16 11:02:09 +00:00
|
|
|
('assets', 'gatherfactsautomation', '*', '*'),
|
2022-12-28 03:25:12 +00:00
|
|
|
('assets', 'commandfilter', '*', '*'),
|
|
|
|
('assets', 'commandfilterrule', '*', '*'),
|
2023-02-21 05:11:56 +00:00
|
|
|
('assets', 'asset', 'add,move', 'assettonode'),
|
|
|
|
('assets', 'asset', 'remove', 'assetfromnode'),
|
2023-02-21 05:40:48 +00:00
|
|
|
('assets', 'asset', 'test', 'account'),
|
|
|
|
('assets', 'asset', 'push', 'assetaccount'),
|
2023-01-16 11:02:09 +00:00
|
|
|
|
|
|
|
('accounts', 'historicalaccount', '*', '*'),
|
|
|
|
('accounts', 'accountbaseautomation', '*', '*'),
|
|
|
|
('accounts', 'verifyaccountautomation', '*', '*'),
|
2024-06-26 09:06:23 +00:00
|
|
|
('accounts', 'gatheredaccount', 'add,change', '*'),
|
2023-01-16 11:02:09 +00:00
|
|
|
('accounts', 'automationexecution', '*', 'automationexecution'),
|
|
|
|
('accounts', 'accountbackupexecution', 'delete,change', 'accountbackupexecution'),
|
|
|
|
('accounts', 'changesecretrecord', 'add,delete,change', 'changesecretrecord'),
|
2023-02-22 06:52:39 +00:00
|
|
|
('accounts', 'account', 'change', 'accountsecret'),
|
2023-02-23 03:27:03 +00:00
|
|
|
('accounts', 'account', 'view', 'historyaccount'),
|
|
|
|
('accounts', 'account', 'view', 'historyaccountsecret'),
|
2024-06-21 11:08:37 +00:00
|
|
|
('accounts', 'accounttemplate', 'change_accounttemplatesecret', 'accounttemplate'),
|
2022-07-14 07:37:00 +00:00
|
|
|
|
2022-02-17 12:13:31 +00:00
|
|
|
('perms', 'userassetgrantedtreenoderelation', '*', '*'),
|
2023-02-14 09:14:24 +00:00
|
|
|
('perms', 'permedaccount', '*', '*'),
|
|
|
|
('perms', 'permedasset', 'view', 'usergroupassets'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('perms', 'usergrantedmappingnode', '*', '*'),
|
|
|
|
('perms', 'permnode', '*', '*'),
|
|
|
|
('perms', 'rebuildusertreetask', '*', '*'),
|
2023-02-14 09:14:24 +00:00
|
|
|
('perms', 'permedasset', '*', 'permedasset'),
|
2022-03-07 11:02:37 +00:00
|
|
|
('perms', 'permedapplication', 'add,change,delete', 'permedapplication'),
|
2023-12-05 03:16:34 +00:00
|
|
|
('rbac', 'contenttype', 'add,change,delete', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('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'),
|
2023-01-16 11:02:09 +00:00
|
|
|
('rbac', 'menupermission', '*', 'menupermission'),
|
2023-02-15 03:29:53 +00:00
|
|
|
('ops', 'adhocexecution', 'view,add,delete,change', '*'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('ops', 'jobexecution', 'change,delete', 'jobexecution'),
|
|
|
|
('ops', 'historicaljob', '*', '*'),
|
2023-02-14 10:05:58 +00:00
|
|
|
('ops', 'celerytask', 'add,change,delete', 'celerytask'),
|
2022-12-22 12:09:20 +00:00
|
|
|
('ops', 'celerytaskexecution', 'add,change,delete', 'celerytaskexecution'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('orgs', 'organizationmember', '*', '*'),
|
2022-03-15 12:23:22 +00:00
|
|
|
('settings', 'setting', 'add,change,delete', 'setting'),
|
2023-02-17 11:58:43 +00:00
|
|
|
('audits', 'joblog', 'add,delete,change', '*'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('audits', 'operatelog', 'add,delete,change', 'operatelog'),
|
2023-02-07 00:52:48 +00:00
|
|
|
('audits', 'activitylog', 'add,delete,change', 'activitylog'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('audits', 'passwordchangelog', 'add,change,delete', 'passwordchangelog'),
|
2022-03-08 09:21:53 +00:00
|
|
|
('audits', 'userloginlog', 'add,change,delete,change', 'userloginlog'),
|
2023-09-15 09:15:15 +00:00
|
|
|
('audits', 'usersession', 'add,delete,change', 'usersession'),
|
2023-06-08 10:04:07 +00:00
|
|
|
('audits', 'ftplog', '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-21 12:19:13 +00:00
|
|
|
('applications', '*', '*', '*'),
|
2024-06-17 09:40:03 +00:00
|
|
|
('settings', 'chatprompt', 'add,delete,change', 'chatprompt'),
|
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', '*', '*'),
|
2023-10-16 07:06:47 +00:00
|
|
|
('rbac', 'orgrole', 'delete,add,change', 'orgrole'),
|
2022-02-17 12:13:31 +00:00
|
|
|
('orgs', 'organization', '*', '*'),
|
|
|
|
('xpack', 'license', '*', '*'),
|
|
|
|
('settings', 'setting', '*', '*'),
|
2022-03-18 09:32:31 +00:00
|
|
|
('tickets', '*', '*', '*'),
|
2023-03-08 07:01:05 +00:00
|
|
|
('ops', 'celerytask', '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', '*', '*'),
|
2023-08-14 08:37:56 +00:00
|
|
|
('authentication', 'accesskey', '*', '*'),
|
|
|
|
('authentication', 'superconnectiontoken', '*', '*'),
|
|
|
|
('authentication', 'temptoken', '*', '*'),
|
2023-09-11 10:15:03 +00:00
|
|
|
('authentication', 'passkey', '*', '*'),
|
2022-03-18 09:44:20 +00:00
|
|
|
('tickets', '*', '*', '*'),
|
2022-04-20 10:50:53 +00:00
|
|
|
('orgs', 'organization', 'view', 'rootorg'),
|
2023-04-20 06:19:13 +00:00
|
|
|
('terminal', 'applet', '*', '*'),
|
|
|
|
('terminal', 'applethost', '*', '*'),
|
2023-10-18 08:35:08 +00:00
|
|
|
('terminal', 'appletpublication', '*', '*'),
|
|
|
|
('terminal', 'applethostdeployment', '*', '*'),
|
2023-06-07 09:39:56 +00:00
|
|
|
('acls', 'loginacl', '*', '*'),
|
|
|
|
('acls', 'connectmethodacl', '*', '*')
|
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)
|