diff --git a/apps/ops/migrations/0034_alter_celerytask_options.py b/apps/ops/migrations/0034_alter_celerytask_options.py new file mode 100644 index 000000000..9645782c4 --- /dev/null +++ b/apps/ops/migrations/0034_alter_celerytask_options.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.16 on 2022-12-27 06:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('ops', '0033_auto_20221223_1536'), + ] + + operations = [ + migrations.AlterModelOptions( + name='celerytask', + options={'ordering': ('name',), 'permissions': [('view_taskmonitor', 'Can view task monitor')], 'verbose_name': 'Celery Task'}, + ), + ] diff --git a/apps/ops/models/celery.py b/apps/ops/models/celery.py index de9633c70..316eca876 100644 --- a/apps/ops/models/celery.py +++ b/apps/ops/models/celery.py @@ -46,6 +46,9 @@ class CeleryTask(models.Model): class Meta: verbose_name = _("Celery Task") ordering = ('name',) + permissions = [ + ('view_taskmonitor', _('Can view task monitor')) + ] class CeleryTaskExecution(models.Model): diff --git a/apps/rbac/const.py b/apps/rbac/const.py index d63c2f610..b4e217977 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -70,7 +70,6 @@ exclude_permissions = ( ('rbac', 'role', '*', '*'), ('ops', 'adhoc', 'delete,change', '*'), ('ops', 'adhocexecution', 'add,delete,change', '*'), - ('ops', 'task', 'add,change', 'task'), ('ops', 'jobexecution', 'change,delete', 'jobexecution'), ('ops', 'historicaljob', '*', '*'), ('ops', 'celerytask', 'add,change,delete', 'celerytask'), @@ -99,9 +98,6 @@ exclude_permissions = ( ('xpack', 'license', '*', '*'), ('xpack', 'syncinstancedetail', 'add,delete,change', 'syncinstancedetail'), ('xpack', 'syncinstancetaskexecution', 'delete,change', 'syncinstancetaskexecution'), - ('xpack', 'changeauthplanexecution', '*', '*'), - ('xpack', 'changeauthplantask', '*', '*'), - ('xpack', 'gatherusertaskexecution', '*', '*'), ('common', 'permission', 'add,delete,view,change', 'permission'), ('terminal', 'command', 'delete,change', 'command'), ('terminal', 'status', 'delete,change', 'status'), diff --git a/apps/rbac/migrations/0011_remove_redundant_permission.py b/apps/rbac/migrations/0011_remove_redundant_permission.py new file mode 100644 index 000000000..15cb8ef47 --- /dev/null +++ b/apps/rbac/migrations/0011_remove_redundant_permission.py @@ -0,0 +1,24 @@ +# Generated by Django 3.2.16 on 2022-12-27 02:41 + +from django.db import migrations + + +def migrate_remove_redundant_permission(apps, *args): + model = apps.get_model('rbac', 'ContentType') + model.objects.filter(app_label='applications').delete() + model.objects.filter(app_label='ops', model='task').delete() + model.objects.filter(app_label='xpack', model__in=[ + 'applicationchangeauthplan', 'applicationchangeauthplanexecution', + 'applicationchangeauthplantask', 'changeauthplan', 'changeauthplanexecution', + 'changeauthplantask', 'gatherusertask', 'gatherusertaskexecution' + ]).delete() + + +class Migration(migrations.Migration): + dependencies = [ + ('rbac', '0010_auto_20221220_1956'), + ] + + operations = [ + migrations.RunPython(migrate_remove_redundant_permission) + ] diff --git a/apps/rbac/tree.py b/apps/rbac/tree.py index e515896c9..14ed53343 100644 --- a/apps/rbac/tree.py +++ b/apps/rbac/tree.py @@ -100,6 +100,8 @@ special_pid_mapper = { 'ops.jobauditlog': 'audits', 'ops.view_celerytask': 'task_center', 'ops.view_celerytaskexecution': 'task_center', + 'ops.view_taskmonitor': 'task_center', + 'ops.adhocexecution': 'task_center', 'ops.job': 'operation_center', 'ops.adhoc': 'operation_center', 'ops.playbook': 'operation_center',