|
| 1 | +AuthZ Django Integration |
| 2 | +######################## |
| 3 | + |
| 4 | +Overview |
| 5 | +******** |
| 6 | + |
| 7 | +The ``openedx.core.djangoapps.authz`` app provides Django integrations for the |
| 8 | +`openedx-authz` authorization framework within ``edx-platform``. |
| 9 | + |
| 10 | +The `openedx-authz` library implements a centralized authorization system based |
| 11 | +on explicit permissions and policy evaluation. This Django app acts as a thin |
| 12 | +integration layer between ``edx-platform`` and the external library, providing |
| 13 | +utilities that make it easier to enforce authorization checks in Django views. |
| 14 | + |
| 15 | +Currently, the app provides a decorator used to enforce AuthZ permissions in |
| 16 | +views. The app may also host additional Django-specific helpers and utilities |
| 17 | +as the integration with the AuthZ framework evolves. |
| 18 | + |
| 19 | +Purpose |
| 20 | +******* |
| 21 | + |
| 22 | +This app exists to: |
| 23 | + |
| 24 | +- Provide Django-specific integrations for the ``openedx-authz`` framework |
| 25 | +- Offer reusable decorators for enforcing authorization checks in views |
| 26 | +- Centralize AuthZ-related utilities used across LMS and Studio |
| 27 | + |
| 28 | +Keeping these integrations in a dedicated app avoids coupling authorization |
| 29 | +logic with unrelated apps and provides a clear location for future extensions. |
| 30 | + |
| 31 | +Location in the Platform |
| 32 | +************************ |
| 33 | + |
| 34 | +The app lives in ``openedx/core/djangoapps`` because the functionality it |
| 35 | +provides is a **platform-level concern shared across LMS and Studio**, rather |
| 36 | +than something specific to either service. |
| 37 | + |
| 38 | +Usage |
| 39 | +***** |
| 40 | + |
| 41 | +The primary utility currently provided by this app is a decorator that enforces |
| 42 | +authorization checks using the AuthZ framework. |
| 43 | + |
| 44 | +Example usage:: |
| 45 | + |
| 46 | + from openedx.core.djangoapps.authz.decorators import authz_permission_required |
| 47 | + |
| 48 | + |
| 49 | + @authz_permission_required("course.read") |
| 50 | + def my_view(request, course_key): |
| 51 | + ... |
| 52 | + |
| 53 | +The decorator ensures that the requesting user has the required permission |
| 54 | +before allowing the view to execute. |
| 55 | + |
| 56 | +Additional parameters may allow compatibility with legacy permission checks |
| 57 | +during the transition to the new authorization framework. |
| 58 | + |
| 59 | +Contents |
| 60 | +******** |
| 61 | + |
| 62 | +The app currently includes: |
| 63 | + |
| 64 | +- **Decorators** for enforcing AuthZ permissions in Django views |
| 65 | +- **Constants** used by the AuthZ integration |
| 66 | +- **Tests** validating decorator behavior |
| 67 | + |
| 68 | +Relationship with ``openedx-authz`` |
| 69 | +*********************************** |
| 70 | + |
| 71 | +This app does not implement the authorization framework itself. Instead, it |
| 72 | +provides Django-specific integrations that connect ``edx-platform`` with the |
| 73 | +external ``openedx-authz`` library. |
| 74 | + |
| 75 | +Keeping these integrations in ``edx-platform`` ensures that the external |
| 76 | +library remains framework-agnostic. |
| 77 | + |
| 78 | +References |
| 79 | +********** |
| 80 | + |
| 81 | +- `openedx-authz repository <https://github.com/openedx/openedx-authz>`_ |
| 82 | +- `openedx-authz documentation <https://openedx-authz.readthedocs.io/>`_ |
0 commit comments