openedx-authz 4.2.0__tar.gz → 4.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/ci.yml +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/CHANGELOG.rst +22 -0
- {openedx_authz-4.2.0/src/openedx_authz.egg-info → openedx_authz-4.4.0}/PKG-INFO +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0035-custom-role-persistence.rst +39 -2
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/pyproject.toml +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/catalog.py +19 -4
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/data.py +2 -7
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/users.py +49 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/constants/__init__.py +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/constants/schema.py +16 -0
- openedx_authz-4.4.0/src/openedx_authz/migrations/0014_add_custom_role_fields.py +36 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/base.py +24 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/schema.py +97 -18
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/data.py +9 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/utils.py +78 -0
- openedx_authz-4.4.0/src/openedx_authz/rest_api/v1/admin_console/filters.py +99 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/serializers.py +24 -2
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/views.py +36 -3
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/api/test_catalog.py +82 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/api/test_users.py +114 -1
- openedx_authz-4.4.0/src/openedx_authz/tests/rest_api/admin_console/test_filters.py +71 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/admin_console/test_views.py +45 -0
- openedx_authz-4.4.0/src/openedx_authz/tests/rest_api/test_utils.py +171 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/test_views.py +287 -2
- openedx_authz-4.4.0/src/openedx_authz/tests/schema/test_schema_models.py +295 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0/src/openedx_authz.egg-info}/PKG-INFO +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz.egg-info/SOURCES.txt +2 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz.egg-info/scm_file_list.json +2 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/uv.lock +423 -381
- openedx_authz-4.2.0/src/openedx_authz/rest_api/v1/admin_console/filters.py +0 -56
- openedx_authz-4.2.0/src/openedx_authz/tests/rest_api/test_utils.py +0 -26
- openedx_authz-4.2.0/src/openedx_authz/tests/schema/test_schema_models.py +0 -145
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.annotation_safe_list.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.editorconfig +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/dependabot.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/add-depr-ticket-to-depr-board.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/add-remove-label-on-comment.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/commitlint.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/release.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/self-assign-issue.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.github/workflows/upgrade-python-requirements.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.gitignore +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.pii_annotations.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/.readthedocs.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/LICENSE +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/MANIFEST.in +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/Makefile +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/catalog-info.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/codecov.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/Makefile +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/_images/architecture-overview.png +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/_static/theme_overrides.css +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/changelog.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/concepts/core_roles_and_permissions/content_library_roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/concepts/core_roles_and_permissions/course_roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/concepts/core_roles_and_permissions/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/concepts/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/conf.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0001-purpose-of-this-repo.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0002-authorization-model-foundation.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0003-jwt-usage.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0004-technology-selection.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0005-architecture-and-data-modeling.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0007-enforcement-mechanisms-mfe.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0008-compatibility-scheme.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0009-authz-for-course-authoring.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0010-course-authoring-flag.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0011-course-authoring-migration-process.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0012-auditability.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0012-glob-support-for-role-assignments.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0013-course-authoring-automatic-migration.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0014-bulk-assignment-queries-without-casbin-enforce.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0015-expose-course-authoring-waffle-flag-state-via-rest-api.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0016-static-and-dynamic-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0017-static-authorization-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0018-authorization-schema-lifecycle.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0019-authorization-schema-discovery.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0020-authorization-schema-internationalization.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0021-authorization-definition-api.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0022-defer-authorization-implications.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0023-extend-static-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0024-api-contract-for-user-grouped-role-assignments.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0025-authorization-schema-source-tracking.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0026-rest-api-domain-ownership-boundary.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0027-cross-domain-filtering-via-openedx-filters.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0028-api-contract-for-role-catalog.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0029-paragon-icon-list-maintenance.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0030-tutor-implementation-authz-schema-discovery.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0031-priority-applies-to-role-extensions-only.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0032-applets-for-built-in-authorization-capabilities.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0033-shared-applet-for-course-team-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0034-permission-dependencies-in-authorization-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0036-api-contract-for-custom-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0037-custom-role-audit-trail.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/0038-hidden-permission-categories-and-permissions.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/decisions.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/getting_started.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/how-tos/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/how-tos/use-built-in-constants.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/internationalization.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/make.bat +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/quickstarts/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/readme.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/references/authorization-schema-json.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/references/authorization-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/references/built-in-constants.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/references/compiled-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/references/compiled-schema.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/references/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/docs/testing.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/manage.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/pylintrc +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/pylintrc_tweaks +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/ruff.toml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/scripts/generate_compiled_schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/scripts/generate_paragon_icons.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/setup.cfg +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/admin.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/roles.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/api/utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/content_libraries/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/content_libraries/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/content_libraries/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/content_libraries/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/content_libraries/schema/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_authoring/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_authoring/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_authoring/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_authoring/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_authoring/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_team_roles/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_team_roles/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_team_roles/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_team_roles/schema/legacy_permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/course_team_roles/schema/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/enrollments/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/enrollments/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/enrollments/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/enrollments/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/enrollments/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_administration/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_administration/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_administration/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_administration/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_administration/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_grading/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_grading/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_grading/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_grading/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/applets/learner_grading/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/apps.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/conf/locale/config.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/constants/permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/constants/roles.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/data.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/adapter.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/apps.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/config/model.conf +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/enforcer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/filter.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/matcher.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/policy.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/renderer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/authz-schema-v1.json +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/compilation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/discovery.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/exceptions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/issues.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/loading.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/paragon_icons.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/parsing.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/snapshot.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/syntax.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/translation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/types/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/types/compilation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/types/definitions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/types/loading.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/schema/validation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/engine/utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/filters.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/handlers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/authz_migrate_course_authoring.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/authz_rollback_course_authoring.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/enforcement.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/extract_schema_translations.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/load_authz_schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/management/commands/load_policies.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0001_add_casbin_dependency.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0002_initial.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0003_usersubject.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0004_contentlibraryscope.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0005_policycachecontrol.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0006_migrate_legacy_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0007_coursescope.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0008_authzcourseauthoringmigrationrun.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0009_roleassignmentaudit.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0010_scope_external_key.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0011_authz_schema_definitions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0012_move_builtin_schema_sources_to_applets.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/0013_add_hidden_to_categories_and_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/migrations/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/authz_migration.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/core.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/engine.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/scopes.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/models/subjects.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/decorators.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/urls.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/admin_console/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/admin_console/serializers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/admin_console/views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/course_authoring/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/course_authoring/pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/course_authoring/views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/fields.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/paginators.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/rest_api/v1/urls.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/settings/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/settings/common.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/settings/production.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/settings/test.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/templates/openedx_authz/base.html +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/api/test_data.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/api/test_roles.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/applets/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/applets/test_builtin_definitions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/applets/test_instructor_dashboard_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/authz/test_resources.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/conftest.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/categories.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_parse/malformed.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_semantics/unknown_category.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_structure/items.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_structure/priority.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/categories.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/permissions.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/test_handlers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/test_models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/test_schema_apply.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/test_schema_pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/integration/test_views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/admin_console/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/course_authoring/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/course_authoring/test_pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/course_authoring/test_views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/mixins.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/rest_api/test_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/role_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/factories.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_apply.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_compilation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_discovery.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_json_schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_load_authz_schema_command.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_loading.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_parsing.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_renderer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_snapshot.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_source_storage.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_syntax.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_translation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_types.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/schema/test_validation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/stubs/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/stubs/apps.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/stubs/migrations/0001_initial.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/stubs/migrations/0002_learningpackage_contentlibrary_learning_package.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/stubs/migrations/0002_userprofile.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/stubs/models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_commands.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_enforcement.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_enforcer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_engine_utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_filter.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_handlers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_imports.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_migrations.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_policy.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/tests/test_utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/urls.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz/utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz.egg-info/dependency_links.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz.egg-info/entry_points.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz.egg-info/requires.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/src/openedx_authz.egg-info/top_level.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tox.ini +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/.gitignore +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/LICENSE.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/MANIFEST.in +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/Makefile +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/pyproject.toml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/tutor_authz/__about__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/tutor_authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/tutor_authz/patches/openedx-common-settings +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/tutor_authz/plugin.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.4.0}/tutor/tutor-contrib-authz/tutor_authz/templates/apps/openedx/config/authz-schema.yml +0 -0
|
@@ -21,7 +21,7 @@ jobs:
|
|
|
21
21
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
22
|
|
|
23
23
|
- name: Install uv
|
|
24
|
-
uses: astral-sh/setup-uv@
|
|
24
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
25
25
|
with:
|
|
26
26
|
enable-cache: true
|
|
27
27
|
python-version: ${{ matrix.python-version }}
|
|
@@ -17,6 +17,10 @@ Unreleased
|
|
|
17
17
|
Added
|
|
18
18
|
=====
|
|
19
19
|
|
|
20
|
+
* Added the storage for custom roles in the role definition table (ADR 0035), in migration
|
|
21
|
+
``0014_add_custom_role_fields``: a ``definition_kind`` (``static`` or ``user_defined``) and a
|
|
22
|
+
``removed_at`` time. Existing roles stay ``static``. The role catalog now returns the stored
|
|
23
|
+
definition kind of each role and leaves out removed custom roles.
|
|
20
24
|
* Added an optional ``hidden`` flag to permission categories and permissions in the authorization
|
|
21
25
|
schema. Hidden permissions, and the permissions of hidden categories, are left out of the
|
|
22
26
|
role and permission catalog, including each role's permission list, but keep their role grants
|
|
@@ -56,6 +60,22 @@ Added
|
|
|
56
60
|
``openedx_authz/engine/schema/paragon_icons.py`` and regenerated with
|
|
57
61
|
``make paragon_icons`` (ADR 0029).
|
|
58
62
|
* Added the Instructor Dashboard permissions from issue #484 for course information, enrollments, learner grading, learner extensions, and cohorts. The ``enrollments``, ``learner_grading``, and ``learner_administration`` applets define them and add them to the ``course_admin`` and ``course_staff`` roles.
|
|
63
|
+
* Added list controls to the role catalog, ``GET /api/authz/v1/roles/``, for the Admin Console
|
|
64
|
+
Roles and Permissions table (ADR 0036):
|
|
65
|
+
|
|
66
|
+
* ``search`` matches role display names, ignoring case.
|
|
67
|
+
* ``definition_kind`` (``static`` or ``user_defined``) keeps only roles of that kind.
|
|
68
|
+
* ``sort_by`` (``display_name``, ``scope_type``, ``user_count`` or ``updated_at``) and ``order``
|
|
69
|
+
(``asc`` or ``desc``) sort the roles. Roles without ``updated_at`` go last, and ties are
|
|
70
|
+
broken by role identifier.
|
|
71
|
+
* Unknown values of ``definition_kind``, ``sort_by`` or ``order`` return 400.
|
|
72
|
+
* ``count`` and the pages reflect the filtered and sorted roles. The ``categories`` and
|
|
73
|
+
``permissions`` catalogs are not filtered.
|
|
74
|
+
|
|
75
|
+
* Added ``user_count`` and ``updated_at`` to each role of the role catalog. ``user_count`` is the
|
|
76
|
+
number of distinct active users with the role in the scopes of the requested types that the
|
|
77
|
+
caller can view. ``updated_at`` is ``null`` for static roles.
|
|
78
|
+
* Added ``get_visible_role_user_counts`` to the public API to count those users.
|
|
59
79
|
|
|
60
80
|
Changed
|
|
61
81
|
========
|
|
@@ -66,6 +86,8 @@ Changed
|
|
|
66
86
|
* **Breaking**: ``GET /api/authz/v1/scopes/`` no longer accepts ``course`` and ``library`` as
|
|
67
87
|
``scope_type`` values. Use ``course-v1`` and ``lib`` instead. Requests with the old values now
|
|
68
88
|
return a 400 validation error, the same as ``/roles/``.
|
|
89
|
+
* The role catalog now lists roles by display name by default, instead of by role identifier.
|
|
90
|
+
Pass ``sort_by`` and ``order`` to choose another order.
|
|
69
91
|
|
|
70
92
|
Removed
|
|
71
93
|
=======
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openedx-authz
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.4.0
|
|
4
4
|
Summary: Open edX AuthZ provides the architecture and foundations of the authorization framework.
|
|
5
5
|
Author-email: Open edX Project <oscm@openedx.org>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -50,8 +50,9 @@ longer needed is removed instead (section 4).
|
|
|
50
50
|
==============================
|
|
51
51
|
|
|
52
52
|
Custom roles are global to the instance. Their IDs use the reserved prefix ``custom_`` followed by
|
|
53
|
-
the display name converted to the role ID format (``[a-z][a-z0-9_]*``). The ID
|
|
54
|
-
never
|
|
53
|
+
the display name converted to the role ID format (``[a-z][a-z0-9_]*``). The ID and the display name
|
|
54
|
+
are set at creation and never change. Editing a custom role changes only its description and
|
|
55
|
+
permissions, matching `ADR 0036`_.
|
|
55
56
|
|
|
56
57
|
The name is converted with the Python standard library, so no transliteration dependency is needed:
|
|
57
58
|
|
|
@@ -145,6 +146,32 @@ those grants and their ``p`` rows in the same deployment. A release that removes
|
|
|
145
146
|
say so in its operator release notes and name this option. A custom role left with no permissions
|
|
146
147
|
remains, so its assignments are kept.
|
|
147
148
|
|
|
149
|
+
6. Where the rules are enforced
|
|
150
|
+
===============================
|
|
151
|
+
|
|
152
|
+
Each kind of role has one writer: the schema loader writes static roles and the custom role API
|
|
153
|
+
writes custom roles. Each rule is enforced by the layer that owns the write it applies to:
|
|
154
|
+
|
|
155
|
+
.. list-table::
|
|
156
|
+
:header-rows: 1
|
|
157
|
+
|
|
158
|
+
* - Rule
|
|
159
|
+
- Enforced by
|
|
160
|
+
* - Role IDs are unique.
|
|
161
|
+
- The database, with a unique constraint on the role ID.
|
|
162
|
+
* - Static role IDs do not start with ``custom_``.
|
|
163
|
+
- Schema validation, before any database change.
|
|
164
|
+
* - Custom role IDs start with ``custom_``, and the ID and display name never change.
|
|
165
|
+
- The custom role API, which builds the ID and only edits the description and permissions.
|
|
166
|
+
* - Custom roles are never hidden.
|
|
167
|
+
- The custom role API, which never sets ``hidden``. The schema loader does not write custom
|
|
168
|
+
roles (section 5).
|
|
169
|
+
* - Only custom roles are removed.
|
|
170
|
+
- The custom role API, which is the only code that sets the removal time.
|
|
171
|
+
|
|
172
|
+
A new rule goes in the layer that writes the data it constrains. The database only enforces
|
|
173
|
+
integrity that every writer needs, such as uniqueness.
|
|
174
|
+
|
|
148
175
|
Consequences
|
|
149
176
|
************
|
|
150
177
|
|
|
@@ -183,6 +210,14 @@ Infer custom roles from missing source links
|
|
|
183
210
|
A role with no source links could also be a leftover or the result of an incomplete write. An
|
|
184
211
|
explicit definition kind avoids the guesswork and is the value the catalog already returns.
|
|
185
212
|
|
|
213
|
+
Database check constraints for the custom role rules
|
|
214
|
+
====================================================
|
|
215
|
+
|
|
216
|
+
Check constraints would reject a row that breaks a rule even if it came from outside the two
|
|
217
|
+
writers. Each kind of role has a single writer that already enforces its rules, and every change to
|
|
218
|
+
a constraint needs a migration that works with the rows already stored. Keeping the rules in the
|
|
219
|
+
writers keeps them in one place per kind of role.
|
|
220
|
+
|
|
186
221
|
References
|
|
187
222
|
**********
|
|
188
223
|
|
|
@@ -193,6 +228,7 @@ References
|
|
|
193
228
|
* `ADR 0023`_
|
|
194
229
|
* `ADR 0025`_
|
|
195
230
|
* `ADR 0028`_
|
|
231
|
+
* `ADR 0036`_
|
|
196
232
|
* `Issue #467`_
|
|
197
233
|
|
|
198
234
|
.. _ADR 0012: 0012-auditability.rst
|
|
@@ -202,4 +238,5 @@ References
|
|
|
202
238
|
.. _ADR 0023: 0023-extend-static-roles.rst
|
|
203
239
|
.. _ADR 0025: 0025-authorization-schema-source-tracking.rst
|
|
204
240
|
.. _ADR 0028: 0028-api-contract-for-role-catalog.rst
|
|
241
|
+
.. _ADR 0036: 0036-api-contract-for-custom-roles.rst
|
|
205
242
|
.. _Issue #467: https://github.com/openedx/openedx-authz/issues/467
|
|
@@ -4,7 +4,6 @@ The catalog is read from the authz schema models, the same data the Casbin polic
|
|
|
4
4
|
rendered from, using a constant number of queries (see ADR 0028).
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from openedx_authz.api.data import DefinitionKind
|
|
8
7
|
from openedx_authz.models.schema import (
|
|
9
8
|
AuthzPermissionCategory,
|
|
10
9
|
AuthzPermissionDefinition,
|
|
@@ -61,7 +60,8 @@ def get_role_catalog(scope_types: list[str]) -> list[dict]:
|
|
|
61
60
|
not hidden. Hidden permissions, and permissions in hidden categories, are left out of
|
|
62
61
|
``permissions``. Roles and their grants are read only from the stored schema definitions, never
|
|
63
62
|
from the Casbin policy, so a role without a stored definition is not listed. Hidden roles are
|
|
64
|
-
never included, even if they are assigned to users.
|
|
63
|
+
never included, even if they are assigned to users. A custom role left with no permissions is
|
|
64
|
+
still listed by its stored resource type, with empty ``permissions``.
|
|
65
65
|
|
|
66
66
|
Args:
|
|
67
67
|
scope_types (list[str]): The scope types (e.g., ['course-v1', 'lib']).
|
|
@@ -78,17 +78,32 @@ def get_role_catalog(scope_types: list[str]) -> list[dict]:
|
|
|
78
78
|
without hidden ones.
|
|
79
79
|
- ``scope_types``: Sorted scope types, among the requested ones, in the role's ``scopes``. Grants
|
|
80
80
|
are rendered from them, so this does not depend on which permissions are hidden.
|
|
81
|
+
- ``updated_at``: When a custom role last changed. Always ``None`` here, because static roles
|
|
82
|
+
have no meaningful edit date.
|
|
81
83
|
"""
|
|
82
|
-
|
|
84
|
+
visible_roles = AuthzRoleDefinition.objects.visible()
|
|
85
|
+
# A custom role left with no grants is matched by its resource type, so an administrator can still
|
|
86
|
+
# add permissions to it or remove it (ADR 0035, ADR 0036).
|
|
87
|
+
roles = (
|
|
88
|
+
visible_roles.with_grants_in_scope_types(scope_types) | visible_roles.user_defined_in_scope_types(scope_types)
|
|
89
|
+
).prefetch_grants_in_scope_types(scope_types)
|
|
83
90
|
return [
|
|
84
91
|
{
|
|
85
92
|
"role": role.role_id,
|
|
93
|
+
# TODO: translate ``display_name`` (and ``description``) here when runtime schema
|
|
94
|
+
# translation lands (ADR 0020). RoleListView searches and sorts these dicts before
|
|
95
|
+
# serializing, so translating in the serializer instead would make search and sort
|
|
96
|
+
# match the English names while the user sees the translated ones. In the same change,
|
|
97
|
+
# switch ``filter_roles`` and ``_role_sort_value`` in ``rest_api/utils.py`` from
|
|
98
|
+
# ``lower()`` to ``casefold()``, so translated names compare without case (e.g. "ß" vs "SS").
|
|
86
99
|
"display_name": role.display_name,
|
|
87
100
|
"description": role.description,
|
|
88
101
|
"icon": role.icon,
|
|
89
|
-
"definition_kind":
|
|
102
|
+
"definition_kind": role.definition_kind,
|
|
90
103
|
"permissions": sorted({grant.permission.identifier for grant in role.grants}),
|
|
91
104
|
"scope_types": sorted(set(role.scopes) & set(scope_types)),
|
|
105
|
+
# TODO: set correct value for ``updated_at`` when custom roles arrive.
|
|
106
|
+
"updated_at": None,
|
|
92
107
|
}
|
|
93
108
|
for role in roles.order_by("role_id")
|
|
94
109
|
]
|
|
@@ -20,6 +20,7 @@ from openedx_authz.authz import (
|
|
|
20
20
|
MANAGE_LIBRARY_TEAM,
|
|
21
21
|
VIEW_LIBRARY_TEAM,
|
|
22
22
|
)
|
|
23
|
+
from openedx_authz.constants.schema import DefinitionKind
|
|
23
24
|
from openedx_authz.data import (
|
|
24
25
|
AUTHZ_POLICY_ATTRIBUTES_SEPARATOR,
|
|
25
26
|
ActionData,
|
|
@@ -41,6 +42,7 @@ __all__ = [
|
|
|
41
42
|
"AuthzBaseClass",
|
|
42
43
|
"ContentLibraryData",
|
|
43
44
|
"CourseOverviewData",
|
|
45
|
+
"DefinitionKind",
|
|
44
46
|
"GroupingPolicyIndex",
|
|
45
47
|
"OrgCourseOverviewGlobData",
|
|
46
48
|
"OrgGlobData",
|
|
@@ -64,13 +66,6 @@ GLOBAL_SCOPE_WILDCARD = "*"
|
|
|
64
66
|
NAMESPACED_KEY_PATTERN = rf"^.+{re.escape(AUTHZ_POLICY_ATTRIBUTES_SEPARATOR)}.+$"
|
|
65
67
|
|
|
66
68
|
|
|
67
|
-
class DefinitionKind(str, Enum):
|
|
68
|
-
"""How a role is defined: ``STATIC`` roles come from the authz schema; ``USER_DEFINED`` is reserved (ADR 0028)."""
|
|
69
|
-
|
|
70
|
-
STATIC = "static"
|
|
71
|
-
USER_DEFINED = "user_defined"
|
|
72
|
-
|
|
73
|
-
|
|
74
69
|
class ScopeMeta(type):
|
|
75
70
|
"""Metaclass for ScopeData to handle dynamic subclass instantiation based on namespace."""
|
|
76
71
|
|
|
@@ -10,6 +10,7 @@ with the role management system, which uses namespaced subjects
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
import logging
|
|
13
|
+
from collections import defaultdict
|
|
13
14
|
|
|
14
15
|
from django.contrib.auth import get_user_model
|
|
15
16
|
from django.db.models import Q
|
|
@@ -60,6 +61,7 @@ __all__ = [
|
|
|
60
61
|
"get_user_role_assignments_filtered",
|
|
61
62
|
"get_all_user_role_assignments_in_scope",
|
|
62
63
|
"get_visible_role_assignments_for_user",
|
|
64
|
+
"get_visible_role_user_counts",
|
|
63
65
|
"get_visible_user_role_assignments_filtered_by_current_user",
|
|
64
66
|
"is_user_allowed",
|
|
65
67
|
"is_user_allowed_in_any_scope",
|
|
@@ -398,6 +400,53 @@ def get_visible_role_assignments_for_user(
|
|
|
398
400
|
return get_user_assignment_map(user_role_assignments)
|
|
399
401
|
|
|
400
402
|
|
|
403
|
+
def get_visible_role_user_counts(
|
|
404
|
+
scope_types: list[str],
|
|
405
|
+
allowed_for_user_external_key: str | None = None,
|
|
406
|
+
) -> dict[str, int]:
|
|
407
|
+
"""Count the distinct active users that hold each role in the given scope types.
|
|
408
|
+
|
|
409
|
+
Backs the ``user_count`` of the role catalog. It counts users, not assignments: a
|
|
410
|
+
user with a role in three courses adds 1 to that role. Only the assignments the viewer can see
|
|
411
|
+
count, using the same scope-based visibility as the team members endpoints, and only
|
|
412
|
+
active users count, so deactivated accounts don't inflate the Members column.
|
|
413
|
+
|
|
414
|
+
Assignments are Casbin grouping policies whose scope column holds full keys or globs, so they
|
|
415
|
+
can't be grouped by scope type in SQL. They are loaded once and counted in Python, with one
|
|
416
|
+
query for the active users.
|
|
417
|
+
|
|
418
|
+
Args:
|
|
419
|
+
scope_types: The scope types to count in (e.g., ``['course-v1', 'lib']``). Org and platform
|
|
420
|
+
globs of a scope type (e.g., ``lib:Org1:*``) count as that scope type.
|
|
421
|
+
allowed_for_user_external_key: The username of the viewer. If None, every assignment counts.
|
|
422
|
+
|
|
423
|
+
Returns:
|
|
424
|
+
dict[str, int]: The user count by role external key. Roles without active, visible users
|
|
425
|
+
are left out.
|
|
426
|
+
"""
|
|
427
|
+
assignments = [
|
|
428
|
+
assignment
|
|
429
|
+
for assignment in get_role_assignments()
|
|
430
|
+
if isinstance(assignment.subject, UserData) and assignment.scope.NAMESPACE in scope_types
|
|
431
|
+
]
|
|
432
|
+
assignments = _filter_allowed_assignments(assignments, user_external_key=allowed_for_user_external_key)
|
|
433
|
+
|
|
434
|
+
active_usernames = set(
|
|
435
|
+
User.objects.filter(
|
|
436
|
+
username__in={assignment.subject.username for assignment in assignments},
|
|
437
|
+
is_active=True,
|
|
438
|
+
).values_list("username", flat=True)
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
usernames_by_role: dict[str, set[str]] = defaultdict(set)
|
|
442
|
+
for assignment in assignments:
|
|
443
|
+
if assignment.subject.username not in active_usernames:
|
|
444
|
+
continue
|
|
445
|
+
for role in assignment.roles:
|
|
446
|
+
usernames_by_role[role.external_key].add(assignment.subject.username)
|
|
447
|
+
return {role: len(usernames) for role, usernames in usernames_by_role.items()}
|
|
448
|
+
|
|
449
|
+
|
|
401
450
|
def is_user_allowed(
|
|
402
451
|
user_external_key: str,
|
|
403
452
|
action_external_key: str,
|
|
@@ -3,6 +3,6 @@ Defined here rather than in api.data so that models and other modules at the
|
|
|
3
3
|
bottom of the import chain can use them without creating circular imports.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from openedx_authz.constants.schema import SchemaOriginKind
|
|
6
|
+
from openedx_authz.constants.schema import CUSTOM_ROLE_ID_PREFIX, DefinitionKind, SchemaOriginKind
|
|
7
7
|
|
|
8
8
|
AUTHZ_POLICY_ATTRIBUTES_SEPARATOR = "^"
|
|
@@ -15,6 +15,22 @@ from enum import Enum
|
|
|
15
15
|
AUTHZ_JSON_SCHEMA_SETTING = "OPENEDX_AUTHZ_JSON_SCHEMA"
|
|
16
16
|
DEFAULT_AUTHZ_JSON_SCHEMA = "openedx_authz.engine.schema/authz-schema-v1.json"
|
|
17
17
|
|
|
18
|
+
CUSTOM_ROLE_ID_PREFIX = "custom_"
|
|
19
|
+
CUSTOM_ROLE_ID_MAX_LENGTH = 64
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DefinitionKind(str, Enum):
|
|
23
|
+
"""How a role is defined (ADR 0028, ADR 0035).
|
|
24
|
+
|
|
25
|
+
``STATIC`` roles come from the authorization schema and are managed by the schema loader.
|
|
26
|
+
``USER_DEFINED`` roles are custom roles created by administrators; the loader never touches
|
|
27
|
+
them. Subclassing ``str`` keeps the members interchangeable with the raw values stored in the
|
|
28
|
+
database.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
STATIC = "static"
|
|
32
|
+
USER_DEFINED = "user_defined"
|
|
33
|
+
|
|
18
34
|
|
|
19
35
|
class SchemaOriginKind(str, Enum):
|
|
20
36
|
"""Whether a schema contribution is a base definition or an extension.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Add the fields that tell custom roles from static roles (ADR 0035).
|
|
2
|
+
|
|
3
|
+
Existing rows are all static roles, so the column defaults leave them correct and no data needs to
|
|
4
|
+
move.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from django.db import migrations, models
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Migration(migrations.Migration):
|
|
11
|
+
"""Add ``definition_kind`` and ``removed_at`` to role definitions."""
|
|
12
|
+
|
|
13
|
+
dependencies = [
|
|
14
|
+
("openedx_authz", "0013_add_hidden_to_categories_and_permissions"),
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
operations = [
|
|
18
|
+
migrations.AddField(
|
|
19
|
+
model_name="authzroledefinition",
|
|
20
|
+
name="definition_kind",
|
|
21
|
+
field=models.CharField(
|
|
22
|
+
choices=[("static", "Static"), ("user_defined", "User defined")],
|
|
23
|
+
default="static",
|
|
24
|
+
max_length=16,
|
|
25
|
+
),
|
|
26
|
+
),
|
|
27
|
+
migrations.AddField(
|
|
28
|
+
model_name="authzroledefinition",
|
|
29
|
+
name="removed_at",
|
|
30
|
+
field=models.DateTimeField(
|
|
31
|
+
blank=True,
|
|
32
|
+
help_text="When the row was removed. Empty while it is in use.",
|
|
33
|
+
null=True,
|
|
34
|
+
),
|
|
35
|
+
),
|
|
36
|
+
]
|
|
@@ -10,6 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
from django.db import models
|
|
11
11
|
|
|
12
12
|
__all__ = [
|
|
13
|
+
"SoftDeletableModel",
|
|
13
14
|
"TimeStampedModel",
|
|
14
15
|
]
|
|
15
16
|
|
|
@@ -35,3 +36,26 @@ class TimeStampedModel(models.Model):
|
|
|
35
36
|
|
|
36
37
|
class Meta:
|
|
37
38
|
abstract = True
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class SoftDeletableModel(models.Model):
|
|
42
|
+
"""Abstract base adding a ``removed_at`` timestamp, so a row can be removed without deleting it.
|
|
43
|
+
|
|
44
|
+
.. no_pii:
|
|
45
|
+
|
|
46
|
+
A removed row keeps its id and its relations, so unique identifiers stay reserved and audit
|
|
47
|
+
records can still name it. ``removed_at`` is empty while the row is in use.
|
|
48
|
+
|
|
49
|
+
Unlike :class:`model_utils.models.SoftDeletableModel`, this stores when the row was removed
|
|
50
|
+
instead of an ``is_removed`` flag, and leaves the default manager alone: each model's queryset
|
|
51
|
+
decides how removed rows are filtered.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
removed_at = models.DateTimeField(
|
|
55
|
+
null=True,
|
|
56
|
+
blank=True,
|
|
57
|
+
help_text="When the row was removed. Empty while it is in use.",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
class Meta:
|
|
61
|
+
abstract = True
|
|
@@ -19,14 +19,19 @@ to avoid name collisions with models from other installed apps.
|
|
|
19
19
|
|
|
20
20
|
from __future__ import annotations
|
|
21
21
|
|
|
22
|
+
from collections.abc import Iterable
|
|
23
|
+
from functools import reduce
|
|
24
|
+
from operator import or_
|
|
25
|
+
|
|
22
26
|
from django.db import models
|
|
23
27
|
from django.db.models import Prefetch
|
|
24
28
|
|
|
25
|
-
from openedx_authz.constants import SchemaOriginKind
|
|
26
|
-
from openedx_authz.models.base import TimeStampedModel
|
|
29
|
+
from openedx_authz.constants import DefinitionKind, SchemaOriginKind
|
|
30
|
+
from openedx_authz.models.base import SoftDeletableModel, TimeStampedModel
|
|
27
31
|
|
|
28
32
|
__all__ = [
|
|
29
33
|
"OriginKind",
|
|
34
|
+
"RoleDefinitionKind",
|
|
30
35
|
"AuthzSchemaSource",
|
|
31
36
|
"AuthzPermissionCategory",
|
|
32
37
|
"AuthzPermissionDefinition",
|
|
@@ -56,6 +61,18 @@ class OriginKind(models.TextChoices):
|
|
|
56
61
|
EXTENSION = SchemaOriginKind.EXTENSION.value, "Extension"
|
|
57
62
|
|
|
58
63
|
|
|
64
|
+
class RoleDefinitionKind(models.TextChoices):
|
|
65
|
+
"""Whether a role comes from the schema or was created by an administrator (ADR 0035).
|
|
66
|
+
|
|
67
|
+
Values are sourced from :class:`openedx_authz.constants.DefinitionKind` so the persistence
|
|
68
|
+
layer and the role catalog share a single source of truth; the second tuple element is the
|
|
69
|
+
human-readable label.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
STATIC = DefinitionKind.STATIC.value, "Static"
|
|
73
|
+
USER_DEFINED = DefinitionKind.USER_DEFINED.value, "User defined"
|
|
74
|
+
|
|
75
|
+
|
|
59
76
|
class AuthzSchemaSourceQuerySet(models.QuerySet):
|
|
60
77
|
"""QuerySet for AuthzSchemaSource with provenance lookups.
|
|
61
78
|
|
|
@@ -151,6 +168,17 @@ class AuthzPermissionDefinitionQuerySet(models.QuerySet):
|
|
|
151
168
|
"""Return the permissions that are not hidden, nor in a hidden category."""
|
|
152
169
|
return self.filter(hidden=False).exclude(category__hidden=True)
|
|
153
170
|
|
|
171
|
+
def with_identifiers(self, identifiers: Iterable[str]) -> "AuthzPermissionDefinitionQuerySet":
|
|
172
|
+
"""Return the permissions whose complete IDs (``namespace.name``) are in ``identifiers``.
|
|
173
|
+
|
|
174
|
+
The complete ID is not a column, so each one is split into its namespace and name. Repeated
|
|
175
|
+
IDs are dropped first, so each one adds a single condition to the query.
|
|
176
|
+
"""
|
|
177
|
+
keys = [identifier.partition(".") for identifier in dict.fromkeys(identifiers)]
|
|
178
|
+
if not keys:
|
|
179
|
+
return self.none()
|
|
180
|
+
return self.filter(reduce(or_, (models.Q(namespace=namespace, name=name) for namespace, _, name in keys)))
|
|
181
|
+
|
|
154
182
|
def supporting_scope_types(self, scope_types: list[str]) -> "AuthzPermissionDefinitionQuerySet":
|
|
155
183
|
"""Return permissions that can be granted in any of the scope types.
|
|
156
184
|
|
|
@@ -234,37 +262,69 @@ class AuthzRoleDefinitionQuerySet(models.QuerySet):
|
|
|
234
262
|
Every method returns a queryset, so they can be combined and refined further.
|
|
235
263
|
"""
|
|
236
264
|
|
|
265
|
+
def active(self) -> "AuthzRoleDefinitionQuerySet":
|
|
266
|
+
"""Return the roles that have not been removed."""
|
|
267
|
+
return self.filter(removed_at__isnull=True)
|
|
268
|
+
|
|
237
269
|
def visible(self) -> "AuthzRoleDefinitionQuerySet":
|
|
238
|
-
"""Return the roles that are
|
|
239
|
-
return self.filter(hidden=False)
|
|
270
|
+
"""Return the roles that are neither removed nor hidden."""
|
|
271
|
+
return self.active().filter(hidden=False)
|
|
272
|
+
|
|
273
|
+
def static(self) -> "AuthzRoleDefinitionQuerySet":
|
|
274
|
+
"""Return the roles declared by the authorization schema."""
|
|
275
|
+
return self.filter(definition_kind=RoleDefinitionKind.STATIC)
|
|
276
|
+
|
|
277
|
+
def user_defined(self) -> "AuthzRoleDefinitionQuerySet":
|
|
278
|
+
"""Return the custom roles created by administrators, including removed ones."""
|
|
279
|
+
return self.filter(definition_kind=RoleDefinitionKind.USER_DEFINED)
|
|
280
|
+
|
|
281
|
+
def user_defined_in_scope_types(self, scope_types: list[str]) -> "AuthzRoleDefinitionQuerySet":
|
|
282
|
+
"""Return the custom roles whose stored resource type is one of the scope types.
|
|
283
|
+
|
|
284
|
+
``scopes`` is a JSON list, which not every database can query for membership, so the
|
|
285
|
+
matching is done in Python over ``scopes`` alone and then narrowed by primary key. Unlike the
|
|
286
|
+
other methods here, this runs that query when called, not when the result is evaluated.
|
|
287
|
+
"""
|
|
288
|
+
wanted = set(scope_types)
|
|
289
|
+
matching = [pk for pk, scopes in self.user_defined().values_list("pk", "scopes") if wanted.intersection(scopes)]
|
|
290
|
+
return self.filter(pk__in=matching)
|
|
240
291
|
|
|
241
292
|
def with_grants_in_scope_types(self, scope_types: list[str]) -> "AuthzRoleDefinitionQuerySet":
|
|
242
|
-
"""Return the roles with a permission grant in any of the scope types
|
|
293
|
+
"""Return the roles with a permission grant in any of the scope types.
|
|
243
294
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
295
|
+
Hidden permissions count as grants here, so a role whose grants are all hidden is still returned.
|
|
296
|
+
"""
|
|
297
|
+
granting_roles = AuthzRolePermission.objects.filter(scope__in=scope_types).values("role_id")
|
|
298
|
+
return self.filter(pk__in=granting_roles)
|
|
299
|
+
|
|
300
|
+
def prefetch_grants_in_scope_types(self, scope_types: list[str]) -> "AuthzRoleDefinitionQuerySet":
|
|
301
|
+
"""Load each role's grants in the scope types, with their permission, in ``grants``.
|
|
302
|
+
|
|
303
|
+
Grants of hidden permissions, or of permissions in hidden categories, are not loaded, so a role
|
|
304
|
+
whose grants are all hidden gets empty ``grants``.
|
|
247
305
|
"""
|
|
248
306
|
grants = (
|
|
249
307
|
AuthzRolePermission.objects.filter(scope__in=scope_types, permission__hidden=False)
|
|
250
308
|
.exclude(permission__category__hidden=True)
|
|
251
309
|
.select_related("permission")
|
|
252
310
|
)
|
|
253
|
-
return (
|
|
254
|
-
self.filter(role_permissions__scope__in=scope_types)
|
|
255
|
-
.distinct()
|
|
256
|
-
.prefetch_related(Prefetch("role_permissions", queryset=grants, to_attr="grants"))
|
|
257
|
-
)
|
|
311
|
+
return self.prefetch_related(Prefetch("role_permissions", queryset=grants, to_attr="grants"))
|
|
258
312
|
|
|
259
313
|
|
|
260
|
-
class AuthzRoleDefinition(TimeStampedModel):
|
|
261
|
-
"""A compiled
|
|
314
|
+
class AuthzRoleDefinition(TimeStampedModel, SoftDeletableModel):
|
|
315
|
+
"""A role definition, either compiled from the schema or created by an administrator.
|
|
262
316
|
|
|
263
317
|
.. no_pii:
|
|
264
318
|
|
|
265
319
|
``hidden`` mirrors ADR 0023: a hidden role is excluded from normal role
|
|
266
320
|
discovery/selection but keeps its assignments, permission checks, and
|
|
267
321
|
reserved id.
|
|
322
|
+
|
|
323
|
+
``definition_kind`` (ADR 0035) tells static roles, which the schema loader manages, from
|
|
324
|
+
custom roles, which it never touches. Removing a custom role sets ``removed_at`` and keeps the
|
|
325
|
+
row, so its id stays reserved and audit records can still name it. The rules that tie the two
|
|
326
|
+
kinds to their ids, ``hidden`` and ``removed_at`` are enforced where each kind is written, not
|
|
327
|
+
by the database (see ADR 0035).
|
|
268
328
|
"""
|
|
269
329
|
|
|
270
330
|
objects = AuthzRoleDefinitionQuerySet.as_manager()
|
|
@@ -275,6 +335,11 @@ class AuthzRoleDefinition(TimeStampedModel):
|
|
|
275
335
|
scopes = models.JSONField(default=list)
|
|
276
336
|
icon = models.CharField(max_length=128, blank=True, null=True)
|
|
277
337
|
hidden = models.BooleanField(default=False)
|
|
338
|
+
definition_kind = models.CharField(
|
|
339
|
+
max_length=16,
|
|
340
|
+
choices=RoleDefinitionKind.choices,
|
|
341
|
+
default=RoleDefinitionKind.STATIC,
|
|
342
|
+
)
|
|
278
343
|
sources = models.ManyToManyField(AuthzSchemaSource, through="AuthzRoleSource", related_name="roles")
|
|
279
344
|
|
|
280
345
|
class Meta:
|
|
@@ -285,17 +350,31 @@ class AuthzRoleDefinition(TimeStampedModel):
|
|
|
285
350
|
return self.role_id
|
|
286
351
|
|
|
287
352
|
|
|
353
|
+
class AuthzRolePermissionQuerySet(models.QuerySet):
|
|
354
|
+
"""QuerySet for AuthzRolePermission, narrowed by the kind of role that owns the grant."""
|
|
355
|
+
|
|
356
|
+
def static(self) -> "AuthzRolePermissionQuerySet":
|
|
357
|
+
"""Return the grants of static roles, the ones the schema loader manages."""
|
|
358
|
+
return self.filter(role__definition_kind=RoleDefinitionKind.STATIC)
|
|
359
|
+
|
|
360
|
+
def user_defined(self) -> "AuthzRolePermissionQuerySet":
|
|
361
|
+
"""Return the grants of custom roles."""
|
|
362
|
+
return self.filter(role__definition_kind=RoleDefinitionKind.USER_DEFINED)
|
|
363
|
+
|
|
364
|
+
|
|
288
365
|
class AuthzRolePermission(TimeStampedModel):
|
|
289
366
|
"""A single role-permission-scope association (one per rendered Casbin ``p`` row).
|
|
290
367
|
|
|
291
368
|
.. no_pii:
|
|
292
369
|
|
|
293
|
-
This records the association declared by the schema; Casbin
|
|
294
|
-
the actual permission check. It is the atomic unit of attribution: a base
|
|
370
|
+
This records the association declared by the schema or chosen for a custom role; Casbin
|
|
371
|
+
still manages the actual permission check. It is the atomic unit of attribution: a base
|
|
295
372
|
association and an extension association on the same role are distinct rows
|
|
296
|
-
with distinct sources.
|
|
373
|
+
with distinct sources. A custom role's grants have no sources.
|
|
297
374
|
"""
|
|
298
375
|
|
|
376
|
+
objects = AuthzRolePermissionQuerySet.as_manager()
|
|
377
|
+
|
|
299
378
|
role = models.ForeignKey(AuthzRoleDefinition, on_delete=models.CASCADE, related_name="role_permissions")
|
|
300
379
|
permission = models.ForeignKey(AuthzPermissionDefinition, on_delete=models.CASCADE, related_name="role_permissions")
|
|
301
380
|
scope = models.CharField(
|
|
@@ -42,6 +42,15 @@ class UserAssignmentSortField(BaseEnum):
|
|
|
42
42
|
EMAIL = "email"
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
class RoleSortField(BaseEnum):
|
|
46
|
+
"""Enum for the role catalog fields to sort by."""
|
|
47
|
+
|
|
48
|
+
DISPLAY_NAME = "display_name"
|
|
49
|
+
SCOPE_TYPE = "scope_type"
|
|
50
|
+
USER_COUNT = "user_count"
|
|
51
|
+
UPDATED_AT = "updated_at"
|
|
52
|
+
|
|
53
|
+
|
|
45
54
|
class SortOrder(BaseEnum):
|
|
46
55
|
"""Enum for the order to sort by."""
|
|
47
56
|
|