Skip to content

feat: Implement AuthZ checks on assets endpoints#38194

Open
rodmgwgu wants to merge 3 commits intoopenedx:masterfrom
WGU-Open-edX:rod/file-permissions
Open

feat: Implement AuthZ checks on assets endpoints#38194
rodmgwgu wants to merge 3 commits intoopenedx:masterfrom
WGU-Open-edX:rod/file-permissions

Conversation

@rodmgwgu
Copy link
Contributor

@rodmgwgu rodmgwgu commented Mar 20, 2026

Description

Implement new AuthZ permission checks over endpoints related with file assets handling in course authoring.

The new AuthZ permission checks only apply when the enable_authz_course_authoring feature flag is enabled for the specific course, or globally, otherwise existing behavior persist.

The following AuthZ permissions are being used:

  • courses.view_files
  • courses.create_files
  • courses.edit_files
  • courses.delete_files

The following endpoints were updated:

  • GET /assets/(courseid)/: List Filles, Permission: courses.view_files
  • GET /assets/(courseid)/(assetid)/usage: Get file info, Permission: courses.view_files
  • POST /assets/(courseid)/: Upload file, Permission: courses.create_files
  • PUT /assets/(courseid)/(assetid)/: Lock file, Permission: courses.edit_files
  • DELETE /assets/(courseid)/(assetid)/: Delete file, Permission: courses.delete_files

Supporting information

Closes openedx/openedx-authz#193

Testing

Verified that:

  • Authorized users can access the endpoints.
  • Unauthorized users receive a 403 response.
  • Legacy permission fallback works as expected.

Running relevant tests manually:

On a cms container (run with tutor dev exec cms bash), do:

pytest -p no:randomly --ds=cms.envs.test cms/djangoapps/contentstore/views/tests/test_assets.py

Deadline

Verawood

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Mar 20, 2026
@openedx-webhooks
Copy link

openedx-webhooks commented Mar 20, 2026

Thanks for the pull request, @rodmgwgu!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Mar 20, 2026
@rodmgwgu rodmgwgu marked this pull request as ready for review March 20, 2026 00:35
'''
course_key = CourseKey.from_string(course_key_string)
if not has_course_author_access(request.user, course_key):
# Everyone should have at least view access to proceedd.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does at least view correspond with L84-L89?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what I meant here is that if you don't have COURSES_VIEW_FILES permission, you won't proceed further, as the other permissions imply a view access.

Perhaps I should reword this to be clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

course_key,
LegacyAuthoringPermission.WRITE
):
raise PermissionDenied()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder the impact of this for non-users of authz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not using authz, this will just repeat the equivalent of has_course_author_access(request.user, course_key) 3 times, which if we already passed on the first check, won't affect on logic.

On performance, my understanding is that has_course_author_access internal logic is cached, so it shouldn't be a big deal.

Alternatively we could explicitly check for the authz flag before this code block to avoid repeated calls, do you think this would be necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up refactoring this for clarity and included the check to avoid calling it repeatedly, thanks for pointing this out.

@rodmgwgu rodmgwgu force-pushed the rod/file-permissions branch from 3e34952 to f900349 Compare March 20, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

Task - RBAC AuthZ - Implement new permissions for files

3 participants