Skip to content

[FC-0118] docs: add ADR for standardizing permissions usage - #38187

Merged
Faraz32123 merged 1 commit into
openedx:docs/ADRs-axim_api_improvementsfrom
edly-io:docs/ADR-standardize_permission_class_usage
Apr 8, 2026
Merged

[FC-0118] docs: add ADR for standardizing permissions usage#38187
Faraz32123 merged 1 commit into
openedx:docs/ADRs-axim_api_improvementsfrom
edly-io:docs/ADR-standardize_permission_class_usage

Conversation

@taimoor-ahmed-1

@taimoor-ahmed-1 taimoor-ahmed-1 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Description

Currently, authorization logic is implemented inconsistently across views, serializers, and custom access checks. This ADR will define a consistent approach using DRF permission classes, object-level permissions, and queryset scoping where appropriate.

Issue: #38163

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 18, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @taimoor-ahmed-1!

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.

Comment thread docs/decisions/0026-standardize-permission-classes.rst Outdated
@taimoor-ahmed-1
taimoor-ahmed-1 force-pushed the docs/ADR-standardize_permission_class_usage branch from bb75b17 to 1326aeb Compare March 18, 2026 11:39
@feanil
feanil requested a review from bmtcril March 18, 2026 15:23
@rodmgwgu

rodmgwgu commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

My initial thoughts:

Although I'm not very familiar with DRF permission classes, this seems like a good approach, I just want to bring some points to the table:

My team is currently working on the RBAC AuthZ project, which aims to improve roles and permissions handling across Open edX, see: https://openedx.atlassian.net/wiki/spaces/OEPM/pages/5364121605/PRD+AuthZ+for+Course+Authoring

We are currently implementing the new permissions system over the CMS, specifically on Course Authoring features.

For now, we are focusing on direct replacements on old permission checks, we recently merged a decorator that is a direct replacement for a legacy one, which supports validating a permission either on the new system or the old one depending on a feature flag: #38156

I think we could probably implement the same thing with this approach (I'll do some reading on it).

However, there are some more involved cases, like the xblock endpoint being implemented here: #38179, where more granular permissions mean that different checks need to be done depending on the request params, I wonder if DRF permission classes could handle this, or we would need to refactor the endpoint (may not be feasible at least for this specific endpoint), or doing an exception.

Thanks for the proposal, I'll do some reading to get more familiar with DRF permissions so we can start using it in our project.

FYI @wgu-taylor-payne @dwong2708

Comment thread docs/decisions/0026-standardize-permission-classes.rst Outdated
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Mar 23, 2026
@taimoor-ahmed-1

Copy link
Copy Markdown
Contributor Author

My initial thoughts:

Although I'm not very familiar with DRF permission classes, this seems like a good approach, I just want to bring some points to the table:

My team is currently working on the RBAC AuthZ project, which aims to improve roles and permissions handling across Open edX, see: https://openedx.atlassian.net/wiki/spaces/OEPM/pages/5364121605/PRD+AuthZ+for+Course+Authoring

We are currently implementing the new permissions system over the CMS, specifically on Course Authoring features.

For now, we are focusing on direct replacements on old permission checks, we recently merged a decorator that is a direct replacement for a legacy one, which supports validating a permission either on the new system or the old one depending on a feature flag: #38156

I think we could probably implement the same thing with this approach (I'll do some reading on it).

However, there are some more involved cases, like the xblock endpoint being implemented here: #38179, where more granular permissions mean that different checks need to be done depending on the request params, I wonder if DRF permission classes could handle this, or we would need to refactor the endpoint (may not be feasible at least for this specific endpoint), or doing an exception.

Thanks for the proposal, I'll do some reading to get more familiar with DRF permissions so we can start using it in our project.

FYI @wgu-taylor-payne @dwong2708

@rodmgwgu Thanks for the detailed context — the RBAC AuthZ work and the CMS/Course Authoring rollout are exactly the kind of direction this ADR is meant to complement.

This proposal is intentionally about the DRF integration surface: we want HTTP APIs to express authorization through permission_classes (and related DRF hooks) so behavior is consistent, discoverable, and testable in one place.

The decorator you merged in #38156 and the broader AuthZ PRD seem to be about policy and enforcement mechanics (including feature-flagged dual implementation). The ADR is about where that enforcement is invoked from API code.

My only question is that whether permission classes were considered as an alternative to decorators?

@rodmgwgu

Copy link
Copy Markdown
Contributor

My initial thoughts:
Although I'm not very familiar with DRF permission classes, this seems like a good approach, I just want to bring some points to the table:
My team is currently working on the RBAC AuthZ project, which aims to improve roles and permissions handling across Open edX, see: https://openedx.atlassian.net/wiki/spaces/OEPM/pages/5364121605/PRD+AuthZ+for+Course+Authoring
We are currently implementing the new permissions system over the CMS, specifically on Course Authoring features.
For now, we are focusing on direct replacements on old permission checks, we recently merged a decorator that is a direct replacement for a legacy one, which supports validating a permission either on the new system or the old one depending on a feature flag: #38156
I think we could probably implement the same thing with this approach (I'll do some reading on it).
However, there are some more involved cases, like the xblock endpoint being implemented here: #38179, where more granular permissions mean that different checks need to be done depending on the request params, I wonder if DRF permission classes could handle this, or we would need to refactor the endpoint (may not be feasible at least for this specific endpoint), or doing an exception.
Thanks for the proposal, I'll do some reading to get more familiar with DRF permissions so we can start using it in our project.
FYI @wgu-taylor-payne @dwong2708

@rodmgwgu Thanks for the detailed context — the RBAC AuthZ work and the CMS/Course Authoring rollout are exactly the kind of direction this ADR is meant to complement.

This proposal is intentionally about the DRF integration surface: we want HTTP APIs to express authorization through permission_classes (and related DRF hooks) so behavior is consistent, discoverable, and testable in one place.

The decorator you merged in #38156 and the broader AuthZ PRD seem to be about policy and enforcement mechanics (including feature-flagged dual implementation). The ADR is about where that enforcement is invoked from API code.

My only question is that whether permission classes were considered as an alternative to decorators?

No, they weren't considered, at this point our objective is to implement the new permissions as drop-in, compatible replacements to existing ones (with some additions), so we are focusing on adapting whatever was already there, which is inconsistent because we have a combination of endpoints that are DRF and other that aren't.

However, I think we should get to an unified way of doing things, we can consider transitioning to permission classes on a future phase of the RBAC project.

@feanil

feanil commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

@taimoor-ahmed-1 I think the critical thing to verify and capture in this ADR is that we're moving to a new underlying permission system (casbin), and that using permission classes won't prevent us from using that underlying permission system and that even if you're using casbin under the hood, the permission checks for DRF view should be done with DRF permission classes. (The permission classes would use casbin under the hood where available.)

@taimoor-ahmed-1

Copy link
Copy Markdown
Contributor Author

@taimoor-ahmed-1 I think the critical thing to verify and capture in this ADR is that we're moving to a new underlying permission system (casbin), and that using permission classes won't prevent us from using that underlying permission system and that even if you're using casbin under the hood, the permission checks for DRF view should be done with DRF permission classes. (The permission classes would use casbin under the hood where available.)

Great callout Feanil, I have updated the ADR accordingly.

@taimoor-ahmed-1 taimoor-ahmed-1 changed the title docs: add ADR for standardizing permissions usage [FC-0118] docs: add ADR for standardizing permissions usage Mar 31, 2026
@feanil

feanil commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

@taimoor-ahmed-1 can you fix the commit messages so that it matches the conventional commit format. Then I think this is good to merge.

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Apr 6, 2026
@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Apr 6, 2026
Currently, authorization logic is implemented inconsistently across views, serializers, and custom access checks. This ADR will define a consistent approach using DRF permission classes, object-level permissions, and queryset scoping where appropriate.
@Faraz32123
Faraz32123 merged commit 30557f2 into openedx:docs/ADRs-axim_api_improvements Apr 8, 2026
66 checks passed
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Apr 8, 2026
Faraz32123 pushed a commit that referenced this pull request Jun 10, 2026
Currently, authorization logic is implemented inconsistently across views, serializers, and custom access checks. This ADR will define a consistent approach using DRF permission classes, object-level permissions, and queryset scoping where appropriate.

Co-authored-by: Taimoor  Ahmed <taimoor.ahmed@A006-01711.local>
Faraz32123 pushed a commit that referenced this pull request Jun 24, 2026
Currently, authorization logic is implemented inconsistently across views, serializers, and custom access checks. This ADR will define a consistent approach using DRF permission classes, object-level permissions, and queryset scoping where appropriate.

Co-authored-by: Taimoor  Ahmed <taimoor.ahmed@A006-01711.local>
Faraz32123 added a commit that referenced this pull request Jun 24, 2026
* docs: add ADR for standardizing serializer usage (#38139)

* docs: explicitly mention API versioning incase of backwards incompatible change (#38188)

Co-authored-by: Muhammad Faraz  Maqsood <faraz.maqsood@A006-01130.local>

* docs: add ADR for standardizing permissions usage (#38187)

Currently, authorization logic is implemented inconsistently across views, serializers, and custom access checks. This ADR will define a consistent approach using DRF permission classes, object-level permissions, and queryset scoping where appropriate.

Co-authored-by: Taimoor  Ahmed <taimoor.ahmed@A006-01711.local>

* docs: minor change in ADR language

* fix: add s back

* docs: migrate restful & legacy django api endpoints to standard drf viewsets (#38191)

* docs: Add ADR for ensuring GET requests are idempotent
Add edx-platform/docs/decisions/0030-ensure-get-requests-are-idempotent.rst as an accepted ADR.
Define policy that GET endpoints must be strictly read-only, with side effects moved to explicit write endpoints or async event pipelines.
Include edx-platform relevance, anti-pattern vs preferred code examples, and rollout guidance for testing and migration.

* docs: add ADR for standardizing API documentation and schema coverage

- Propose adoption of drf-spectacular across Open edX services
- Require @extend_schema decorators for all API endpoints
- Document request/response schemas, status codes, and error conditions

* docs: remove incorrect ADR number

* docs: address api-doc-tools deprecation in ADR per review feedback

- Add context explaining what api-doc-tools is and its relationship
  to drf-yasg
- Document deprecation and archival of api-doc-tools as a consequence
- Add migration guide mapping api-doc-tools decorators and URL helpers
  to their drf-spectacular equivalents
- Add rejected alternative for updating api-doc-tools internals
- Add rollout step for final archival cutover

Closes review comment by @feanil

* docs: expand ADR-0027 with api-doc-tools deprecation and drf-yasg incompatibility analysis

Address review feedback on FC-0118 ADR 0027:

- Add context paragraph explaining what api-doc-tools is (drf-yasg shim,
  decorators it provides, schema view, OpenAPI 2.0 output)
- Document deprecation of api-doc-tools and drf-yasg as a consequence,
  including transition-window behavior
- Add detailed 8-point incompatibility analysis explaining why drf-yasg
  cannot be replaced with drf-spectacular inside api-doc-tools (recorded
  in the ADR itself for future reference)
- Add migration plan for existing api-doc-tools consumers with concrete
  decorator/import/setting mapping
- Update Rollout Plan to track api-doc-tools removal
- Add references to drf-spectacular migration guide, drf-yasg upstream
  status, and api-doc-tools repository

* chore: fix edx-mantained to edX-platform

* docs: add ADR for standardizing pagination across APIs (#38300)

* docs: add ADR for api versioning strategy (#38304)

* docs: add ADR for standardizing filtering/sorting parameters (#38303)

* docs: add ADR-0029 standardized error responses decision (#38246)

* docs: add ADR for merging similar endpoints (#38262)

* docs: ADR for normalizing nested json apis (#38305)

* docs: add separate example for input & output serializers

* docs: ADR for documenting and consolidating internal MFE APIs (#38309)

* docs: ADR for documenting and consolidating internal MFE APIs
Define a plan to document all undocumented internal LMS APIs consumed
by MFEs into stable, OpenAPI-described contracts. Introduces a
consolidated config endpoint pattern with optional course/user context,
authentication boundaries, and a rollout plan following OEP-21 DEPR
process.

* docs: add ADR for canonical MFE configuration endpoint

Record that /api/frontend_site_config/v1/ is the canonical endpoint for
MFE/front-end runtime configuration (frontend-base SiteConfig, OEP-65) and
that /api/mfe_config/v1 is legacy, on the DEPR path tracked in #37255 and
added, and that user-context data (roles, permissions) belongs on
resource-oriented endpoints rather than on a configuration payload.
Documentation/schema coverage is deferred to the API Documentation &
Schema Coverage ADR (#38189).

Partially supersedes ADR 0001 (MFE Config API).

Part of FC-0118 Open edX REST API standardization (#38137).
Refs #38280

* docs: add ADR for standardizing authentication patterns (#38301)

* docs: add ADR for standardizing authentication patterns

* docs: resolve confusion & update the ADR based on OEP-0042

* docs: support multiple valid auth schemes & deprecate BearerAuthentication

* docs: change wording for decisions a bit.

* docs: add real examples in accordance with our updated decisions

* docs: sync ADR with edx-drf-extensions issue 284

openedx/edx-drf-extensions#284

* docs: make doc more explicit & address comments

* docs: move Bearer auth depr plan out of ADR

Move BearerAuthentication depr plan out of this doc So that it resides in single place i.e. to its deprecation ticket.

* docs: add a pointer file in oauth_dispatch for this ADR

* docs: make decision more clear

* docs: make authentication_classes usage more clearer

* docs: adress the comment related to session authentication

* chore: correct file number w.r.t order of the ADRs

---------

Co-authored-by: Muhammad Faraz  Maqsood <faraz.maqsood@A006-01130.local>
Co-authored-by: Taimoor Ahmed <68893403+taimoor-ahmed-1@users.noreply.github.com>
Co-authored-by: Taimoor  Ahmed <taimoor.ahmed@A006-01711.local>
Co-authored-by: Robert Raposa <rraposa@edx.org>
Co-authored-by: Abdul Muqadim <abdul.muqadim@A006-01811.local>
Co-authored-by: Abdul Muqadim <abdul.muqadim@192.168.1.7>
Co-authored-by: Abdul-Muqadim-Arbisoft <139064778+Abdul-Muqadim-Arbisoft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants