fix: scope agent token deletion to organization (IDOR)
This commit is contained in:
parent
1590f78bdc
commit
a7f3133a5b
1 changed files with 5 additions and 1 deletions
|
|
@ -166,7 +166,11 @@ defmodule ToweropsWeb.AgentLive.Index do
|
|||
# Verify the agent token belongs to the current org before deleting
|
||||
agent_token = Agents.get_agent_token!(id)
|
||||
|
||||
if agent_token.organization_id != organization.id do
|
||||
is_superuser = Scope.superuser?(socket.assigns.current_scope)
|
||||
is_cloud_poller = is_nil(agent_token.organization_id)
|
||||
belongs_to_org = agent_token.organization_id == organization.id
|
||||
|
||||
if not belongs_to_org and not (is_superuser and is_cloud_poller) do
|
||||
{:noreply, put_flash(socket, :error, t_equipment("Agent not found"))}
|
||||
else
|
||||
case Agents.delete_agent_token(id) do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue