fix(api): honor dataset read grants for raw downloads#4163
Open
GautamSharma99 wants to merge 1 commit into
Open
fix(api): honor dataset read grants for raw downloads#4163GautamSharma99 wants to merge 1 commit into
GautamSharma99 wants to merge 1 commit into
Conversation
Signed-off-by: GautamSharma99 <gautamsharma99067@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #<ISSUE_NUMBER>
This PR fixes inconsistent authorization and missing-dataset handling in the dataset read endpoints:
GET /api/v1/datasets/{dataset_id}/dataGET /api/v1/datasets/{dataset_id}/data/{data_id}/rawThe raw-download endpoint first verified that the caller had
readpermission on the requested dataset and that the requesteddata item belonged to that dataset. It then called
get_data(user.id, data_id), which applied an additional owner-only check.As a result, users with a valid dataset read grant could list a shared dataset's data but could not download the raw content
of those same data items.
This change uses the data record already obtained through the authorized dataset membership check. It does not relax the
owner-only behavior of
get_data()globally.The PR also fixes missing and inaccessible dataset handling. Both endpoints previously checked whether the authorization
result was
None, although the helper returns a list or raisesPermissionDeniedError. This made the intended 404 handlingineffective and left empty results vulnerable to
[0]indexing.A shared response helper now:
ErrorResponseDTOusing valid Pydantic keyword arguments.Acceptance Criteria
readgrant can download raw data belonging to that dataset.IndexError.Implementation Details
The raw-download flow now follows this authorization sequence:
readpermission on the requested dataset.data_idis present in that dataset.This preserves the important cross-dataset boundary: possession of read access to one dataset cannot be used to download a
data item from another dataset.
The owner-only
get_data()method was left unchanged because other operations may rely on its existing semantics.Tests
Added or updated coverage for:
PermissionDeniedError.Commands run: