openedx.core.djangoapps.authz package#
Submodules#
openedx.core.djangoapps.authz.apps module#
Django app configuration for authz app.
- class openedx.core.djangoapps.authz.apps.AuthzConfig(app_name, app_module)#
Bases:
AppConfigDjango 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'#
openedx.core.djangoapps.authz.constants module#
Constants used by the Open edX Authorization (AuthZ) framework.
openedx.core.djangoapps.authz.decorators module#
Decorators for AuthZ-based permissions enforcement.
- openedx.core.djangoapps.authz.decorators.authz_permission_required(authz_permission: str, legacy_permission: LegacyAuthoringPermission | None = None) Callable#
Decorator enforcing course author permissions via AuthZ with optional legacy fallback.
This decorator checks if the requesting user has the specified AuthZ permission for the course. If AuthZ is not enabled for the course, and a legacy_permission is provided, it falls back to checking the legacy permission.
- Raises:
DeveloperErrorResponseException – If the user does not have the required permissions.
- openedx.core.djangoapps.authz.decorators.get_course_key(course_id: str) CourseKey#
Given a course_id string, attempts to parse it as a CourseKey. If that fails, attempts to parse it as a UsageKey and extract the course key from it.
- openedx.core.djangoapps.authz.decorators.user_has_course_permission(user: AbstractUser, authz_permission: str, course_key: CourseKey, legacy_permission: LegacyAuthoringPermission | None = None) bool#
Checks if the user has the specified AuthZ permission for the course, with optional fallback to legacy permissions.