Skip to content

feat: extract overridable permission methods from ObjectTagView#541

Open
wgu-taylor-payne wants to merge 1 commit intoopenedx:mainfrom
WGU-Open-edX:tpayne/object-tag-view-authz-refactor
Open

feat: extract overridable permission methods from ObjectTagView#541
wgu-taylor-payne wants to merge 1 commit intoopenedx:mainfrom
WGU-Open-edX:tpayne/object-tag-view-authz-refactor

Conversation

@wgu-taylor-payne
Copy link
Copy Markdown

@wgu-taylor-payne wgu-taylor-payne commented Apr 14, 2026

Extract overridable permission methods from ObjectTagView

Context

As part of the RBAC AuthZ course authoring milestone, edx-platform needs to substitute openedx-authz permission checks for the legacy django-rules checks on content tagging endpoints. The current ObjectTagView inlines its permission logic, forcing downstream overrides to duplicate significant parent view code — which is fragile and hard to maintain.

Changes

views.py — Extract 2 overridable access-control methods from ObjectTagView:

Method Called from Purpose
check_view_object_tags_permission(object_id, taxonomy) get_queryset Gate read access to object tags
check_can_tag_object_permission(object_id, taxonomy) update Gate write access

serializers.py — Extract 1 overridable method for response-field permission computation:

Method Serializer Purpose
get_can_tag_object(obj_tag) ObjectTagsByTaxonomySerializer Compute can_tag_object bool for response

ObjectTagMinimalSerializer.get_can_delete_objecttag was already overridable — no changes needed.

All default implementations preserve existing behavior exactly.

Design

Access-control checks (check_*) live on the view — they gate endpoint access from get_queryset and update. Response-field computation (get_can_tag_object, get_can_delete_objecttag) lives on the serializers, consistent with how all other permission fields (can_change_taxonomy, can_delete_tag, etc.) work in this package. This keeps a clean separation: views own access control, serializers own data representation.

Why

This lets downstream platforms (e.g., edx-platform) override permission logic without duplicating get_queryset, update, or retrieve code. The companion edx-platform PR is openedx/openedx-platform#38292.

Testing

Co-authored with Kiro

@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 Apr 14, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 14, 2026

Thanks for the pull request, @wgu-taylor-payne!

This repository is currently maintained by @axim-engineering.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the tagging REST API to make permission checks overridable in ObjectTagView, enabling downstream consumers (e.g., edx-platform) to swap legacy django-rules checks with openedx-authz without duplicating view logic.

Changes:

  • Extracts 4 permission-related methods from ObjectTagView for downstream override.
  • Updates serializers to delegate can_tag_object / can_delete_objecttag computation to the view methods when available in serializer context.
  • Bumps repository version to 0.40.0.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/openedx_tagging/rest_api/v1/views.py Adds overridable permission hooks and rewires get_queryset/update to call them.
src/openedx_tagging/rest_api/v1/serializers.py Delegates permission-field computation to view methods (when present in serializer context).
src/openedx_core/__init__.py Version bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/openedx_tagging/rest_api/v1/serializers.py Outdated
@wgu-taylor-payne wgu-taylor-payne marked this pull request as ready for review April 15, 2026 16:52
Copy link
Copy Markdown

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple of nit comments. Thanks!

Comment thread src/openedx_tagging/rest_api/v1/views.py
Comment thread src/openedx_tagging/rest_api/v1/views.py
Comment thread src/openedx_tagging/rest_api/v1/serializers.py Outdated
@wgu-taylor-payne
Copy link
Copy Markdown
Author

I've updated openedx/openedx-platform#38292 to temporarily point to these changes until they are merged and released.

@ormsbee
Copy link
Copy Markdown
Contributor

ormsbee commented Apr 15, 2026

@wgu-taylor-payne: Can you please squash and update your commit message?

FYI to @jesperhodge, @mgwozdz-unicon, @bradenmacdonald, @tbain that this permissions refactoring is landing for tagging.

…erializers

Extract permission checks into overridable methods so downstream
platforms can substitute their own authorization logic without
duplicating parent view code.

views.py:
- check_view_object_tags_permission — gates read access (get_queryset)
- check_can_tag_object_permission — gates write access (update)

serializers.py:
- ObjectTagsByTaxonomySerializer.get_can_tag_object — computes
  can_tag_object bool for response

Co-authored-by: Kiro <kiro@amazon.com>
@wgu-taylor-payne wgu-taylor-payne force-pushed the tpayne/object-tag-view-authz-refactor branch from 130d3ba to 11c0255 Compare April 15, 2026 20:21
@wgu-taylor-payne
Copy link
Copy Markdown
Author

@wgu-taylor-payne: Can you please squash and update your commit message?

@ormsbee I've squashed and updated the commit message.

Copy link
Copy Markdown
Contributor

@dwong2708 dwong2708 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@ormsbee ormsbee self-requested a review April 15, 2026 21:41
Copy link
Copy Markdown
Contributor

@ormsbee ormsbee left a comment

Choose a reason for hiding this comment

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

Sorry folks, I need to hold up this merge for a bit while I check with Axim folks on how to handle Kiro-assisted code. Our current policy accepts Copilot, Claude, and OpenAI. While Kiro largely delegates out to Claude, it does have some of its own models as well, and I need to check with our team and legal before I can merge this. Apologies for the delay.

I'm submitting this as "Request changes" even though there are no real changes to be made, just to indicate that it's not ready for merge at this time.

@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Apr 16, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Apr 16, 2026
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). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

7 participants