Skip to content

Commit

Permalink
Respect site_read role in View Data view. Fixes #355.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkuchenb committed May 1, 2021
1 parent 9380ff6 commit e4fdbc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions datameta/api/ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ def post(request: Request):
and_filters = [
# This clause joins the EXISTS subquery with the main query
MetaDataSet.id==MetaDataSetFilter.id,
# This clause restricts the results to submissions of the user's group
Submission.group_id == auth_user.group_id
]

# This clause restricts the results to submissions of the user's group
if not authz.view_mset_any(auth_user):
and_filters.append(Submission.group_id == auth_user.group_id)

# Additionally, if a search pattern was requested, we create a clause
# implementing the the search and add it to the AND clause
if searches:
Expand Down
6 changes: 3 additions & 3 deletions datameta/security/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ def has_data_access(user, data_user_id, data_group_id=None, was_submitted=False)
(not was_submitted and data_user_id and data_user_id == user.id)
))

def view_mset_any(user):
return user.site_read

def view_apikey(user, target_user):
return user_is_target(user, target_user)

Expand Down Expand Up @@ -78,6 +75,9 @@ def submit_mset(user, mds_obj):
def delete_mset(user, mdata_set):
return user.id == mdata_set.user_id

def view_mset_any(user):
return user.site_read

def view_mset(user, mds_obj):
was_submitted = bool(mds_obj.submission_id is not None)
group_id = mds_obj.submission.group_id if was_submitted else None
Expand Down

0 comments on commit e4fdbc4

Please sign in to comment.