-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: introduce authz_permission_required decorator #38156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wgu-taylor-payne
merged 2 commits into
openedx:master
from
WGU-Open-edX:dwong2708/new-permissions-checklists
Mar 18, 2026
+723
−6
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| AuthZ Django Integration | ||
| ######################## | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| The ``openedx.core.djangoapps.authz`` app provides Django integrations for the | ||
| `openedx-authz` authorization framework within ``edx-platform``. | ||
|
|
||
| The `openedx-authz` library implements a centralized authorization system based | ||
| on explicit permissions and policy evaluation. This Django app acts as a thin | ||
| integration layer between ``edx-platform`` and the external library, providing | ||
| utilities that make it easier to enforce authorization checks in Django views. | ||
|
|
||
| Currently, the app provides a decorator used to enforce AuthZ permissions in | ||
| views. The app may also host additional Django-specific helpers and utilities | ||
| as the integration with the AuthZ framework evolves. | ||
|
|
||
| Purpose | ||
| ******* | ||
|
|
||
| This app exists to: | ||
|
|
||
| - Provide Django-specific integrations for the ``openedx-authz`` framework | ||
| - Offer reusable decorators for enforcing authorization checks in views | ||
| - Centralize AuthZ-related utilities used across LMS and Studio | ||
|
|
||
| Keeping these integrations in a dedicated app avoids coupling authorization | ||
| logic with unrelated apps and provides a clear location for future extensions. | ||
|
|
||
| Location in the Platform | ||
| ************************ | ||
|
|
||
| The app lives in ``openedx/core/djangoapps`` because the functionality it | ||
| provides is a **platform-level concern shared across LMS and Studio**, rather | ||
| than something specific to either service. | ||
|
|
||
| Usage | ||
| ***** | ||
|
|
||
| The primary utility currently provided by this app is a decorator that enforces | ||
| authorization checks using the AuthZ framework. | ||
|
|
||
| Example usage:: | ||
|
|
||
| from openedx.core.djangoapps.authz.decorators import authz_permission_required | ||
|
|
||
|
|
||
| @authz_permission_required("course.read") | ||
| def my_view(request, course_key): | ||
| ... | ||
|
|
||
| The decorator ensures that the requesting user has the required permission | ||
| before allowing the view to execute. | ||
|
|
||
| Additional parameters may allow compatibility with legacy permission checks | ||
| during the transition to the new authorization framework. | ||
|
|
||
| Contents | ||
| ******** | ||
|
|
||
| The app currently includes: | ||
|
|
||
| - **Decorators** for enforcing AuthZ permissions in Django views | ||
| - **Constants** used by the AuthZ integration | ||
| - **Tests** validating decorator behavior | ||
|
|
||
| Relationship with ``openedx-authz`` | ||
| *********************************** | ||
|
|
||
| This app does not implement the authorization framework itself. Instead, it | ||
| provides Django-specific integrations that connect ``edx-platform`` with the | ||
| external ``openedx-authz`` library. | ||
|
|
||
| Keeping these integrations in ``edx-platform`` ensures that the external | ||
| library remains framework-agnostic. | ||
|
|
||
| References | ||
| ********** | ||
|
|
||
| - `openedx-authz repository <https://github.com/openedx/openedx-authz>`_ | ||
| - `openedx-authz documentation <https://openedx-authz.readthedocs.io/>`_ |
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """Django app configuration for authz app.""" | ||
|
|
||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class AuthzConfig(AppConfig): | ||
mariajgrimaldi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Django application configuration for the Open edX Authorization (AuthZ) app. | ||
|
|
||
| This app provides a centralized location for integrations with the | ||
| openedx-authz library, including permission helpers, decorators, | ||
| and other utilities used to enforce RBAC-based authorization across | ||
| the platform.""" | ||
|
|
||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'openedx.core.djangoapps.authz' | ||
| verbose_name = "Open edX Authorization Framework" | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.