Skip to content

Commit

Permalink
rework agent uninstall perms fixes #1673
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Nov 9, 2023
1 parent 64ba69b commit 564aaaf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.7 on 2023-11-09 19:57

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("accounts", "0035_role_can_manage_reports_role_can_view_reports"),
]

operations = [
migrations.RemoveField(
model_name="role",
name="can_ping_agents",
),
]
1 change: 0 additions & 1 deletion api/tacticalrmm/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class Role(BaseAuditModel):

# agents
can_list_agents = models.BooleanField(default=False)
can_ping_agents = models.BooleanField(default=False)
can_use_mesh = models.BooleanField(default=False)
can_uninstall_agents = models.BooleanField(default=False)
can_update_agents = models.BooleanField(default=False)
Expand Down
7 changes: 0 additions & 7 deletions api/tacticalrmm/agents/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ def has_permission(self, r, view) -> bool:
return _has_perm(r, "can_update_agents")


class PingAgentPerms(permissions.BasePermission):
def has_permission(self, r, view) -> bool:
return _has_perm(r, "can_ping_agents") and _has_perm_on_agent(
r.user, view.kwargs["agent_id"]
)


class ManageProcPerms(permissions.BasePermission):
def has_permission(self, r, view) -> bool:
return _has_perm(r, "can_manage_procs") and _has_perm_on_agent(
Expand Down
1 change: 0 additions & 1 deletion api/tacticalrmm/agents/tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,6 @@ def test_agent_actions_permissions(self, nats_cmd, sleep):
{"method": "post", "action": "recover", "role": "can_recover_agents"},
{"method": "post", "action": "reboot", "role": "can_reboot_agents"},
{"method": "patch", "action": "reboot", "role": "can_reboot_agents"},
{"method": "get", "action": "ping", "role": "can_ping_agents"},
{"method": "get", "action": "meshcentral", "role": "can_use_mesh"},
{"method": "post", "action": "meshcentral/recover", "role": "can_use_mesh"},
{"method": "get", "action": "processes", "role": "can_manage_procs"},
Expand Down
3 changes: 1 addition & 2 deletions api/tacticalrmm/agents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
InstallAgentPerms,
ManageProcPerms,
MeshPerms,
PingAgentPerms,
RebootAgentPerms,
RecoverAgentPerms,
RunBulkPerms,
Expand Down Expand Up @@ -402,7 +401,7 @@ def update_agents(request):


@api_view(["GET"])
@permission_classes([IsAuthenticated, PingAgentPerms])
@permission_classes([IsAuthenticated, AgentPerms])
def ping(request, agent_id):
agent = get_object_or_404(Agent, agent_id=agent_id)
status = AGENT_STATUS_OFFLINE
Expand Down

0 comments on commit 564aaaf

Please sign in to comment.