Skip to content

Commit

Permalink
Ensure data-only viewers cannot use SPI to access user list
Browse files Browse the repository at this point in the history
  • Loading branch information
milesmcc committed May 20, 2024
1 parent 999e091 commit 51b4cd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions platform/lib/platform/permissions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ defmodule Platform.Permissions do
alias Platform.Projects.ProjectMembership
alias Platform.API.APIToken

def can_view_project_members?(%User{} = user, %Project{} = project) do
membership = Projects.get_project_membership_by_user_and_project(user, project)

can_view_project?(
user,
project,
membership
) and membership.role != :data_only_viewer
end

def can_view_project?(%User{} = user, %Project{} = project) do
can_view_project?(
user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule PlatformWeb.SPIController do

get_project_users = fn project ->
if is_nil(project) or
not Permissions.can_view_project?(conn.assigns.current_user, project) do
not Permissions.can_view_project_members?(conn.assigns.current_user, project) do
raise PlatformWeb.Errors.NotFound, "Project not found"
end

Expand Down

0 comments on commit 51b4cd3

Please sign in to comment.