openedx-authz 4.2.0__tar.gz → 4.3.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.3.0}/CHANGELOG.rst +18 -0
- {openedx_authz-4.2.0/src/openedx_authz.egg-info → openedx_authz-4.3.0}/PKG-INFO +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/pyproject.toml +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/catalog.py +10 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/users.py +49 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/data.py +9 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/utils.py +78 -0
- openedx_authz-4.3.0/src/openedx_authz/rest_api/v1/admin_console/filters.py +99 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/serializers.py +24 -2
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/views.py +36 -3
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/api/test_catalog.py +1 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/api/test_users.py +114 -1
- openedx_authz-4.3.0/src/openedx_authz/tests/rest_api/admin_console/test_filters.py +71 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/admin_console/test_views.py +45 -0
- openedx_authz-4.3.0/src/openedx_authz/tests/rest_api/test_utils.py +171 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/test_views.py +287 -2
- {openedx_authz-4.2.0 → openedx_authz-4.3.0/src/openedx_authz.egg-info}/PKG-INFO +1 -1
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz.egg-info/SOURCES.txt +1 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz.egg-info/scm_file_list.json +1 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.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 → openedx_authz-4.3.0}/.annotation_safe_list.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.editorconfig +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/dependabot.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/add-depr-ticket-to-depr-board.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/add-remove-label-on-comment.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/ci.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/commitlint.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/release.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/self-assign-issue.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.github/workflows/upgrade-python-requirements.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.gitignore +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.pii_annotations.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/.readthedocs.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/LICENSE +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/MANIFEST.in +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/Makefile +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/catalog-info.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/codecov.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/Makefile +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/_images/architecture-overview.png +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/_static/theme_overrides.css +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/changelog.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/concepts/core_roles_and_permissions/content_library_roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/concepts/core_roles_and_permissions/course_roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/concepts/core_roles_and_permissions/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/concepts/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/conf.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0001-purpose-of-this-repo.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0002-authorization-model-foundation.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0003-jwt-usage.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0004-technology-selection.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0005-architecture-and-data-modeling.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0007-enforcement-mechanisms-mfe.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0008-compatibility-scheme.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0009-authz-for-course-authoring.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0010-course-authoring-flag.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0011-course-authoring-migration-process.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0012-auditability.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0012-glob-support-for-role-assignments.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0013-course-authoring-automatic-migration.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0014-bulk-assignment-queries-without-casbin-enforce.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0015-expose-course-authoring-waffle-flag-state-via-rest-api.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0016-static-and-dynamic-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0017-static-authorization-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0018-authorization-schema-lifecycle.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0019-authorization-schema-discovery.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0020-authorization-schema-internationalization.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0021-authorization-definition-api.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0022-defer-authorization-implications.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0023-extend-static-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0024-api-contract-for-user-grouped-role-assignments.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0025-authorization-schema-source-tracking.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0026-rest-api-domain-ownership-boundary.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0027-cross-domain-filtering-via-openedx-filters.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0028-api-contract-for-role-catalog.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0029-paragon-icon-list-maintenance.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0030-tutor-implementation-authz-schema-discovery.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0031-priority-applies-to-role-extensions-only.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0032-applets-for-built-in-authorization-capabilities.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0033-shared-applet-for-course-team-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0034-permission-dependencies-in-authorization-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0035-custom-role-persistence.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0036-api-contract-for-custom-roles.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0037-custom-role-audit-trail.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/0038-hidden-permission-categories-and-permissions.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/decisions.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/getting_started.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/how-tos/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/how-tos/use-built-in-constants.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/internationalization.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/make.bat +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/quickstarts/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/readme.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/references/authorization-schema-json.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/references/authorization-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/references/built-in-constants.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/references/compiled-schema.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/references/compiled-schema.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/references/index.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/docs/testing.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/manage.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/pylintrc +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/pylintrc_tweaks +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/ruff.toml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/scripts/generate_compiled_schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/scripts/generate_paragon_icons.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/setup.cfg +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/admin.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/data.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/roles.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/api/utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/content_libraries/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/content_libraries/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/content_libraries/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/content_libraries/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/content_libraries/schema/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_authoring/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_authoring/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_authoring/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_authoring/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_authoring/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_team_roles/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_team_roles/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_team_roles/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_team_roles/schema/legacy_permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/course_team_roles/schema/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/enrollments/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/enrollments/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/enrollments/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/enrollments/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/enrollments/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_administration/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_administration/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_administration/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_administration/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_administration/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_grading/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_grading/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_grading/constants.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_grading/schema/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/applets/learner_grading/schema/role_extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/apps.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/conf/locale/config.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/constants/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/constants/permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/constants/roles.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/constants/schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/data.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/adapter.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/apps.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/config/model.conf +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/enforcer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/filter.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/matcher.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/policy.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/renderer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/authz-schema-v1.json +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/compilation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/discovery.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/exceptions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/issues.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/loading.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/paragon_icons.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/parsing.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/snapshot.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/syntax.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/translation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/types/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/types/compilation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/types/definitions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/types/loading.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/schema/validation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/engine/utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/filters.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/handlers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/authz_migrate_course_authoring.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/authz_rollback_course_authoring.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/enforcement.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/extract_schema_translations.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/load_authz_schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/management/commands/load_policies.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0001_add_casbin_dependency.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0002_initial.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0003_usersubject.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0004_contentlibraryscope.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0005_policycachecontrol.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0006_migrate_legacy_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0007_coursescope.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0008_authzcourseauthoringmigrationrun.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0009_roleassignmentaudit.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0010_scope_external_key.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0011_authz_schema_definitions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0012_move_builtin_schema_sources_to_applets.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/0013_add_hidden_to_categories_and_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/migrations/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/authz_migration.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/base.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/core.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/engine.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/scopes.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/models/subjects.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/decorators.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/urls.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/admin_console/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/admin_console/serializers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/admin_console/views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/course_authoring/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/course_authoring/pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/course_authoring/views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/fields.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/paginators.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/rest_api/v1/urls.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/settings/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/settings/common.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/settings/production.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/settings/test.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/templates/openedx_authz/base.html +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/api/test_data.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/api/test_roles.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/applets/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/applets/test_builtin_definitions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/applets/test_instructor_dashboard_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/authz/test_resources.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/conftest.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/categories.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/permissions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_compiled/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_parse/malformed.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_semantics/unknown_category.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_structure/items.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/invalid_structure/priority.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/categories.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/extensions.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/permissions.yml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/fixtures/schema_pipeline/valid/roles.yaml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/test_handlers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/test_models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/test_schema_apply.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/test_schema_pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/integration/test_views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/admin_console/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/course_authoring/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/course_authoring/test_pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/course_authoring/test_views.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/mixins.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/rest_api/test_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/role_permissions.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/factories.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_apply.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_compilation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_discovery.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_json_schema.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_load_authz_schema_command.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_loading.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_parsing.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_pipeline.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_renderer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_schema_models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_snapshot.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_source_storage.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_syntax.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_translation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_types.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/schema/test_validation.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/stubs/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/stubs/apps.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/stubs/migrations/0001_initial.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/stubs/migrations/0002_learningpackage_contentlibrary_learning_package.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/stubs/migrations/0002_userprofile.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/stubs/models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_commands.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_enforcement.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_enforcer.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_engine_utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_filter.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_handlers.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_imports.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_migrations.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_models.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_policy.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/tests/test_utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/urls.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz/utils.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz.egg-info/dependency_links.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz.egg-info/entry_points.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz.egg-info/requires.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/src/openedx_authz.egg-info/top_level.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tox.ini +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/.gitignore +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/LICENSE.txt +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/MANIFEST.in +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/Makefile +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/README.rst +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/pyproject.toml +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/tutor_authz/__about__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/tutor_authz/__init__.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/tutor_authz/patches/openedx-common-settings +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/tutor_authz/plugin.py +0 -0
- {openedx_authz-4.2.0 → openedx_authz-4.3.0}/tutor/tutor-contrib-authz/tutor_authz/templates/apps/openedx/config/authz-schema.yml +0 -0
|
@@ -56,6 +56,22 @@ Added
|
|
|
56
56
|
``openedx_authz/engine/schema/paragon_icons.py`` and regenerated with
|
|
57
57
|
``make paragon_icons`` (ADR 0029).
|
|
58
58
|
* 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.
|
|
59
|
+
* Added list controls to the role catalog, ``GET /api/authz/v1/roles/``, for the Admin Console
|
|
60
|
+
Roles and Permissions table (ADR 0036):
|
|
61
|
+
|
|
62
|
+
* ``search`` matches role display names, ignoring case.
|
|
63
|
+
* ``definition_kind`` (``static`` or ``user_defined``) keeps only roles of that kind.
|
|
64
|
+
* ``sort_by`` (``display_name``, ``scope_type``, ``user_count`` or ``updated_at``) and ``order``
|
|
65
|
+
(``asc`` or ``desc``) sort the roles. Roles without ``updated_at`` go last, and ties are
|
|
66
|
+
broken by role identifier.
|
|
67
|
+
* Unknown values of ``definition_kind``, ``sort_by`` or ``order`` return 400.
|
|
68
|
+
* ``count`` and the pages reflect the filtered and sorted roles. The ``categories`` and
|
|
69
|
+
``permissions`` catalogs are not filtered.
|
|
70
|
+
|
|
71
|
+
* Added ``user_count`` and ``updated_at`` to each role of the role catalog. ``user_count`` is the
|
|
72
|
+
number of distinct active users with the role in the scopes of the requested types that the
|
|
73
|
+
caller can view. ``updated_at`` is ``null`` for static roles.
|
|
74
|
+
* Added ``get_visible_role_user_counts`` to the public API to count those users.
|
|
59
75
|
|
|
60
76
|
Changed
|
|
61
77
|
========
|
|
@@ -66,6 +82,8 @@ Changed
|
|
|
66
82
|
* **Breaking**: ``GET /api/authz/v1/scopes/`` no longer accepts ``course`` and ``library`` as
|
|
67
83
|
``scope_type`` values. Use ``course-v1`` and ``lib`` instead. Requests with the old values now
|
|
68
84
|
return a 400 validation error, the same as ``/roles/``.
|
|
85
|
+
* The role catalog now lists roles by display name by default, instead of by role identifier.
|
|
86
|
+
Pass ``sort_by`` and ``order`` to choose another order.
|
|
69
87
|
|
|
70
88
|
Removed
|
|
71
89
|
=======
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openedx-authz
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.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
|
|
@@ -78,17 +78,27 @@ 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
|
roles = AuthzRoleDefinition.objects.visible().with_grants_in_scope_types(scope_types)
|
|
83
85
|
return [
|
|
84
86
|
{
|
|
85
87
|
"role": role.role_id,
|
|
88
|
+
# TODO: translate ``display_name`` (and ``description``) here when runtime schema
|
|
89
|
+
# translation lands (ADR 0020). RoleListView searches and sorts these dicts before
|
|
90
|
+
# serializing, so translating in the serializer instead would make search and sort
|
|
91
|
+
# match the English names while the user sees the translated ones. In the same change,
|
|
92
|
+
# switch ``filter_roles`` and ``_role_sort_value`` in ``rest_api/utils.py`` from
|
|
93
|
+
# ``lower()`` to ``casefold()``, so translated names compare without case (e.g. "ß" vs "SS").
|
|
86
94
|
"display_name": role.display_name,
|
|
87
95
|
"description": role.description,
|
|
88
96
|
"icon": role.icon,
|
|
89
97
|
"definition_kind": DefinitionKind.STATIC.value,
|
|
90
98
|
"permissions": sorted({grant.permission.identifier for grant in role.grants}),
|
|
91
99
|
"scope_types": sorted(set(role.scopes) & set(scope_types)),
|
|
100
|
+
# TODO: set correct value for ``updated_at`` when custom roles arrive.
|
|
101
|
+
"updated_at": None,
|
|
92
102
|
}
|
|
93
103
|
for role in roles.order_by("role_id")
|
|
94
104
|
]
|
|
@@ -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,
|
|
@@ -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
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Utility functions for the Open edX AuthZ REST API."""
|
|
2
2
|
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
3
5
|
from openedx_authz.api.data import (
|
|
4
6
|
GLOBAL_SCOPE_WILDCARD,
|
|
5
7
|
ScopeData,
|
|
@@ -8,6 +10,7 @@ from openedx_authz.api.utils import get_scope_display_name_map
|
|
|
8
10
|
from openedx_authz.rest_api.data import (
|
|
9
11
|
AssignmentSortField,
|
|
10
12
|
BaseEnum,
|
|
13
|
+
RoleSortField,
|
|
11
14
|
ScopesTypeField,
|
|
12
15
|
SearchField,
|
|
13
16
|
SerializedAssignment,
|
|
@@ -204,6 +207,81 @@ def sort_user_assignments(
|
|
|
204
207
|
return _sort_by_field(assignments, sort_by, order, UserAssignmentSortField)
|
|
205
208
|
|
|
206
209
|
|
|
210
|
+
def filter_roles(roles: list[dict], search: str | None, definition_kind: str | None) -> list[dict]:
|
|
211
|
+
"""Filter role catalog entries by display name and definition kind.
|
|
212
|
+
|
|
213
|
+
Runs in Python, not in the database, so that the search can match the name the user sees once
|
|
214
|
+
static role names are translated with gettext (ADR 0036). Runtime translation isn't wired yet,
|
|
215
|
+
so for now the search matches the stored English ``display_name``.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
roles (list[dict]): Role catalog entries, as returned by ``get_role_catalog``.
|
|
219
|
+
search (str | None): Optional case-insensitive substring of ``display_name``.
|
|
220
|
+
definition_kind (str | None): Optional ``DefinitionKind`` value to keep.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
list[dict]: The matching roles, preserving the original order.
|
|
224
|
+
"""
|
|
225
|
+
if not search and not definition_kind:
|
|
226
|
+
return roles
|
|
227
|
+
|
|
228
|
+
search = search.lower() if search else None
|
|
229
|
+
return [
|
|
230
|
+
role
|
|
231
|
+
for role in roles
|
|
232
|
+
if (not search or search in (role.get("display_name") or "").lower())
|
|
233
|
+
and (not definition_kind or role.get("definition_kind") == definition_kind)
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _role_sort_value(role: dict, sort_by: str) -> str | int | datetime | None:
|
|
238
|
+
"""Return the value of a role to sort by, or None when the role has no value for the field."""
|
|
239
|
+
if sort_by == RoleSortField.DISPLAY_NAME:
|
|
240
|
+
return (role.get("display_name") or "").lower()
|
|
241
|
+
if sort_by == RoleSortField.SCOPE_TYPE:
|
|
242
|
+
return ",".join(role.get("scope_types") or [])
|
|
243
|
+
if sort_by == RoleSortField.USER_COUNT:
|
|
244
|
+
return role.get("user_count") or 0
|
|
245
|
+
return role.get("updated_at")
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def sort_roles(
|
|
249
|
+
roles: list[dict],
|
|
250
|
+
sort_by: RoleSortField = RoleSortField.DISPLAY_NAME,
|
|
251
|
+
order: SortOrder = SortOrder.ASC,
|
|
252
|
+
) -> list[dict]:
|
|
253
|
+
"""Sort role catalog entries by a field and order.
|
|
254
|
+
|
|
255
|
+
Unlike :func:`_sort_by_field`, the values are not all strings: ``user_count`` sorts as a
|
|
256
|
+
number and ``updated_at`` as a date. Roles without a value (``updated_at`` of static roles)
|
|
257
|
+
go last in both orders, so a descending sort still starts with the most recently updated
|
|
258
|
+
role. Ties are broken by ``role`` identifier, ascending, so pages are stable.
|
|
259
|
+
|
|
260
|
+
Args:
|
|
261
|
+
roles (list[dict]): Role catalog entries, with ``user_count`` and ``updated_at`` set.
|
|
262
|
+
sort_by (RoleSortField, optional): The field to sort by. Defaults to ``display_name``.
|
|
263
|
+
order (SortOrder, optional): The order to sort by. Defaults to ``asc``.
|
|
264
|
+
|
|
265
|
+
Raises:
|
|
266
|
+
ValueError: If the sort field is invalid.
|
|
267
|
+
ValueError: If the sort order is invalid.
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
list[dict]: The sorted roles.
|
|
271
|
+
"""
|
|
272
|
+
if sort_by not in RoleSortField.values():
|
|
273
|
+
raise ValueError(f"Invalid field: '{sort_by}'. Must be one of {RoleSortField.values()}")
|
|
274
|
+
if order not in SortOrder.values():
|
|
275
|
+
raise ValueError(f"Invalid order: '{order}'. Must be one of {SortOrder.values()}")
|
|
276
|
+
|
|
277
|
+
# Sort by identifier first: the sort below is stable, also when reversed, so this breaks ties.
|
|
278
|
+
by_role = sorted(roles, key=lambda role: role["role"])
|
|
279
|
+
with_value = [role for role in by_role if _role_sort_value(role, sort_by) is not None]
|
|
280
|
+
without_value = [role for role in by_role if _role_sort_value(role, sort_by) is None]
|
|
281
|
+
with_value.sort(key=lambda role: _role_sort_value(role, sort_by), reverse=order == SortOrder.DESC)
|
|
282
|
+
return with_value + without_value
|
|
283
|
+
|
|
284
|
+
|
|
207
285
|
def inject_scope_display_names(assignments: list[SerializedAssignment]) -> None:
|
|
208
286
|
"""Set ``scope_display_name`` in-place on serialized assignments using one bulk lookup.
|
|
209
287
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Custom DRF filter backends for the Open edX AuthZ REST API."""
|
|
2
|
+
|
|
3
|
+
from rest_framework.filters import BaseFilterBackend
|
|
4
|
+
|
|
5
|
+
from openedx_authz.rest_api.data import (
|
|
6
|
+
AssignmentSortField,
|
|
7
|
+
SearchField,
|
|
8
|
+
SortField,
|
|
9
|
+
SortOrder,
|
|
10
|
+
UserAssignmentSortField,
|
|
11
|
+
)
|
|
12
|
+
from openedx_authz.rest_api.utils import (
|
|
13
|
+
filter_roles,
|
|
14
|
+
filter_users,
|
|
15
|
+
sort_assignments,
|
|
16
|
+
sort_roles,
|
|
17
|
+
sort_user_assignments,
|
|
18
|
+
sort_users,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TeamMemberSearchFilter(BaseFilterBackend):
|
|
23
|
+
"""Filter team members by a search term."""
|
|
24
|
+
|
|
25
|
+
def filter_queryset(self, request, queryset, view):
|
|
26
|
+
search = request.query_params.get("search")
|
|
27
|
+
return filter_users(users=queryset, search=search, roles=None)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TeamMemberOrderingFilter(BaseFilterBackend):
|
|
31
|
+
"""Sort team members by a given field and order.
|
|
32
|
+
|
|
33
|
+
An empty ``sort_by`` or ``order`` (e.g. ``?sort_by=``) falls back to the default, as the query
|
|
34
|
+
serializer does. Passing the empty string on would make the sort raise ``ValueError`` (a 500).
|
|
35
|
+
The other ordering backends below follow the same rule.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
def filter_queryset(self, request, queryset, view):
|
|
39
|
+
sort_by = request.query_params.get("sort_by") or SortField.USERNAME
|
|
40
|
+
order = request.query_params.get("order") or SortOrder.ASC
|
|
41
|
+
return sort_users(users=queryset, sort_by=sort_by, order=order)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class TeamMemberAssignmentsOrderingFilter(BaseFilterBackend):
|
|
45
|
+
"""Sort team member assignments by a given field and order."""
|
|
46
|
+
|
|
47
|
+
def filter_queryset(self, request, queryset, view):
|
|
48
|
+
sort_by = request.query_params.get("sort_by") or AssignmentSortField.ROLE
|
|
49
|
+
order = request.query_params.get("order") or SortOrder.ASC
|
|
50
|
+
return sort_assignments(assignments=queryset, sort_by=sort_by, order=order)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class UserAssignmentsSearchFilter(BaseFilterBackend):
|
|
54
|
+
"""Filter user assignments by a search term over full_name, username, and email."""
|
|
55
|
+
|
|
56
|
+
def filter_queryset(self, request, queryset, view):
|
|
57
|
+
search = request.query_params.get("search")
|
|
58
|
+
if not search:
|
|
59
|
+
return queryset
|
|
60
|
+
search = search.lower()
|
|
61
|
+
return [
|
|
62
|
+
item
|
|
63
|
+
for item in queryset
|
|
64
|
+
if any(search in (item.get(field) or "").lower() for field in SearchField.values())
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class UserAssignmentsOrderingFilter(BaseFilterBackend):
|
|
69
|
+
"""Sort user assignments by a given field and order."""
|
|
70
|
+
|
|
71
|
+
def filter_queryset(self, request, queryset, view):
|
|
72
|
+
sort_by = request.query_params.get("sort_by") or UserAssignmentSortField.FULL_NAME
|
|
73
|
+
order = request.query_params.get("order") or SortOrder.ASC
|
|
74
|
+
return sort_user_assignments(assignments=queryset, sort_by=sort_by, order=order)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class RoleSearchFilter(BaseFilterBackend):
|
|
78
|
+
"""Filter role catalog entries by display name and definition kind.
|
|
79
|
+
|
|
80
|
+
Reads ``view.validated_query_params``, the output of ``ListRolesQuerySerializer``, instead of the
|
|
81
|
+
raw query string, so the values are already stripped, lowercased and defaulted. Reading the raw
|
|
82
|
+
``search`` would miss matches for values with surrounding spaces.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
def filter_queryset(self, request, queryset, view):
|
|
86
|
+
params = view.validated_query_params
|
|
87
|
+
return filter_roles(roles=queryset, search=params["search"], definition_kind=params["definition_kind"])
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class RoleOrderingFilter(BaseFilterBackend):
|
|
91
|
+
"""Sort role catalog entries by a given field and order.
|
|
92
|
+
|
|
93
|
+
Reads ``view.validated_query_params``, like :class:`RoleSearchFilter`, so empty values already
|
|
94
|
+
carry the serializer defaults and only supported values reach :func:`sort_roles`.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
def filter_queryset(self, request, queryset, view):
|
|
98
|
+
params = view.validated_query_params
|
|
99
|
+
return sort_roles(roles=queryset, sort_by=params["sort_by"], order=params["order"])
|
|
@@ -5,7 +5,7 @@ from rest_framework import serializers
|
|
|
5
5
|
|
|
6
6
|
from openedx_authz import api
|
|
7
7
|
from openedx_authz.api.data import GLOBAL_SCOPE_WILDCARD, DefinitionKind
|
|
8
|
-
from openedx_authz.rest_api.data import ScopesTypeField, SortField, SortOrder
|
|
8
|
+
from openedx_authz.rest_api.data import RoleSortField, ScopesTypeField, SortField, SortOrder
|
|
9
9
|
from openedx_authz.rest_api.utils import get_generic_scope, parse_scope_types
|
|
10
10
|
from openedx_authz.rest_api.v1.fields import CommaSeparatedListField, LowercaseCharField
|
|
11
11
|
|
|
@@ -193,9 +193,29 @@ class ListUsersInRoleWithScopeResponseSerializer(serializers.Serializer): # pyl
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
class ListRolesQuerySerializer(serializers.Serializer): # pylint: disable=abstract-method
|
|
196
|
-
"""Serializer for validating the query parameters of the role catalog.
|
|
196
|
+
"""Serializer for validating the query parameters of the role catalog.
|
|
197
|
+
|
|
198
|
+
``search``, ``sort_by`` and ``order`` reuse the names of the team members endpoints,
|
|
199
|
+
and ``definition_kind`` filters by how a role is defined. Unknown values are a 400.
|
|
200
|
+
"""
|
|
197
201
|
|
|
198
202
|
scope_types = serializers.CharField()
|
|
203
|
+
search = LowercaseCharField(required=False, default=None)
|
|
204
|
+
definition_kind = serializers.ChoiceField(
|
|
205
|
+
required=False,
|
|
206
|
+
choices=[(e.value, e.name) for e in DefinitionKind],
|
|
207
|
+
default=None,
|
|
208
|
+
)
|
|
209
|
+
sort_by = serializers.ChoiceField(
|
|
210
|
+
required=False,
|
|
211
|
+
choices=[(e.value, e.name) for e in RoleSortField],
|
|
212
|
+
default=RoleSortField.DISPLAY_NAME.value,
|
|
213
|
+
)
|
|
214
|
+
order = serializers.ChoiceField(
|
|
215
|
+
required=False,
|
|
216
|
+
choices=[(e.value, e.name) for e in SortOrder],
|
|
217
|
+
default=SortOrder.ASC.value,
|
|
218
|
+
)
|
|
199
219
|
|
|
200
220
|
def validate_scope_types(self, value: str) -> list[str]:
|
|
201
221
|
"""Convert the comma-separated scope types to a list of unique, supported scope types.
|
|
@@ -242,6 +262,8 @@ class RoleCatalogRoleSerializer(serializers.Serializer): # pylint: disable=abst
|
|
|
242
262
|
definition_kind = serializers.ChoiceField(choices=[(e.value, e.name) for e in DefinitionKind])
|
|
243
263
|
permissions = serializers.ListField(child=serializers.CharField(max_length=255))
|
|
244
264
|
scope_types = serializers.ListField(child=serializers.CharField(max_length=255))
|
|
265
|
+
user_count = serializers.IntegerField()
|
|
266
|
+
updated_at = serializers.DateTimeField(allow_null=True)
|
|
245
267
|
|
|
246
268
|
|
|
247
269
|
class RoleCatalogMetaSerializer(serializers.Serializer): # pylint: disable=abstract-method
|
|
@@ -31,6 +31,7 @@ from openedx_authz.filters import PermissionValidationRequested, RoleAssignmentR
|
|
|
31
31
|
from openedx_authz.rest_api.data import RoleOperationError, RoleOperationStatus
|
|
32
32
|
from openedx_authz.rest_api.decorators import authz_permissions, view_auth_classes
|
|
33
33
|
from openedx_authz.rest_api.utils import filter_users, sort_users
|
|
34
|
+
from openedx_authz.rest_api.v1.admin_console.filters import RoleOrderingFilter, RoleSearchFilter
|
|
34
35
|
from openedx_authz.rest_api.v1.paginators import AuthZAPIViewPagination
|
|
35
36
|
from openedx_authz.rest_api.v1.permissions import AnyScopePermission, DynamicScopePermission, ScopeTypePermission
|
|
36
37
|
from openedx_authz.rest_api.v1.serializers import (
|
|
@@ -420,17 +421,24 @@ class RoleListView(APIView):
|
|
|
420
421
|
|
|
421
422
|
- scope_types (Required): Comma-separated list of scope types to query, with at least one value.
|
|
422
423
|
Each one is ``course-v1`` or ``lib``.
|
|
424
|
+
- search (Optional): Case-insensitive search on the role display name
|
|
425
|
+
- definition_kind (Optional): Only list roles of this kind: ``static`` or ``user_defined``
|
|
426
|
+
- sort_by (Optional): Field to sort by. Options: display_name, scope_type, user_count, updated_at.
|
|
427
|
+
Defaults to display_name. Roles without ``updated_at`` go last; ties are broken by role.
|
|
428
|
+
- order (Optional): Sort order, 'asc' or 'desc'. Defaults to asc
|
|
423
429
|
- page (Optional): Page number for pagination of the roles
|
|
424
430
|
- page_size (Optional): Number of roles per page
|
|
425
431
|
|
|
426
432
|
**Response Format**
|
|
427
433
|
|
|
428
|
-
- count, next, previous: Pagination of the roles
|
|
434
|
+
- count, next, previous: Pagination of the roles, after search and filtering
|
|
429
435
|
- scope_types: The requested scope types (``course-v1``, ``lib``)
|
|
430
436
|
- categories: Categories used by the permissions (id, display_name, description, icon)
|
|
431
437
|
- permissions: Permissions of the scope types (id, display_name, description, icon, category_id, scope_types)
|
|
432
438
|
- results: Roles, each with role, display_name, description, icon, definition_kind, permissions
|
|
433
|
-
(ids of entries of ``permissions``), scope_types (requested scope types in which the role has grants)
|
|
439
|
+
(ids of entries of ``permissions``), scope_types (requested scope types in which the role has grants),
|
|
440
|
+
user_count (distinct active users with the role in the scopes of those types the caller can view)
|
|
441
|
+
and updated_at (when a custom role last changed; null for static roles)
|
|
434
442
|
|
|
435
443
|
**Authentication and Permissions**
|
|
436
444
|
|
|
@@ -442,16 +450,34 @@ class RoleListView(APIView):
|
|
|
442
450
|
**Example Request**
|
|
443
451
|
|
|
444
452
|
GET /api/authz/v1/roles/?scope_types=course-v1&page=1&page_size=10
|
|
453
|
+
|
|
454
|
+
GET /api/authz/v1/roles/?scope_types=course-v1,lib&search=admin&sort_by=user_count&order=desc
|
|
445
455
|
"""
|
|
446
456
|
|
|
447
457
|
pagination_class = AuthZAPIViewPagination
|
|
458
|
+
filter_backends = [RoleSearchFilter, RoleOrderingFilter]
|
|
448
459
|
permission_classes = [ScopeTypePermission]
|
|
460
|
+
# Set by ``get`` from ``ListRolesQuerySerializer`` and read by the filter backends.
|
|
461
|
+
validated_query_params: dict | None = None
|
|
449
462
|
|
|
450
463
|
@apidocs.schema(
|
|
451
464
|
parameters=[
|
|
452
465
|
apidocs.query_parameter(
|
|
453
466
|
"scope_types", str, description="Comma-separated scope types to query: `course-v1` and/or `lib`"
|
|
454
467
|
),
|
|
468
|
+
apidocs.query_parameter("search", str, description="Search roles by display name"),
|
|
469
|
+
apidocs.query_parameter(
|
|
470
|
+
"definition_kind", str, description="Only list roles of this kind: `static` or `user_defined`"
|
|
471
|
+
),
|
|
472
|
+
apidocs.query_parameter(
|
|
473
|
+
"sort_by",
|
|
474
|
+
str,
|
|
475
|
+
description="The field to sort by. Options: display_name, scope_type, user_count, updated_at. "
|
|
476
|
+
"Defaults to display_name",
|
|
477
|
+
),
|
|
478
|
+
apidocs.query_parameter(
|
|
479
|
+
"order", str, description="The order to sort by. Options: asc, desc. Defaults to asc"
|
|
480
|
+
),
|
|
455
481
|
apidocs.query_parameter("page", int, description="Page number for pagination"),
|
|
456
482
|
apidocs.query_parameter("page_size", int, description="Number of roles per page"),
|
|
457
483
|
],
|
|
@@ -466,10 +492,17 @@ class RoleListView(APIView):
|
|
|
466
492
|
"""Retrieve the roles, permissions and categories available for one or more scope types."""
|
|
467
493
|
query_serializer = ListRolesQuerySerializer(data=request.query_params)
|
|
468
494
|
query_serializer.is_valid(raise_exception=True)
|
|
469
|
-
|
|
495
|
+
# The filter backends read the validated values, so the serializer is the only parser.
|
|
496
|
+
self.validated_query_params = query_serializer.validated_data
|
|
497
|
+
scope_types = self.validated_query_params["scope_types"]
|
|
470
498
|
|
|
471
499
|
permission_catalog = api.get_permission_catalog(scope_types)
|
|
472
500
|
role_catalog = api.get_role_catalog(scope_types)
|
|
501
|
+
user_counts = api.get_visible_role_user_counts(scope_types, request.user.username)
|
|
502
|
+
for role in role_catalog:
|
|
503
|
+
role["user_count"] = user_counts.get(role["role"], 0)
|
|
504
|
+
for backend in self.filter_backends:
|
|
505
|
+
role_catalog = backend().filter_queryset(request, role_catalog, self)
|
|
473
506
|
|
|
474
507
|
paginator = self.pagination_class()
|
|
475
508
|
page = paginator.paginate_queryset(role_catalog, request)
|
|
@@ -30,6 +30,7 @@ from openedx_authz.api.users import (
|
|
|
30
30
|
get_user_role_assignments_in_scope,
|
|
31
31
|
get_user_role_assignments_per_scope_type,
|
|
32
32
|
get_visible_role_assignments_for_user,
|
|
33
|
+
get_visible_role_user_counts,
|
|
33
34
|
get_visible_user_role_assignments_filtered_by_current_user,
|
|
34
35
|
is_user_allowed,
|
|
35
36
|
is_user_allowed_in_any_scope,
|
|
@@ -57,7 +58,7 @@ from openedx_authz.authz import (
|
|
|
57
58
|
MANAGE_LIBRARY_TEAM,
|
|
58
59
|
PUBLISH_LIBRARY_CONTENT,
|
|
59
60
|
)
|
|
60
|
-
from openedx_authz.tests.api.test_roles import RolesTestSetupMixin
|
|
61
|
+
from openedx_authz.tests.api.test_roles import BaseRolesTestCase, RolesTestSetupMixin
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
class UserAssignmentsSetupMixin(RolesTestSetupMixin):
|
|
@@ -945,6 +946,118 @@ class TestGetVisibleRoleAssignmentsForUser(UserAssignmentsSetupMixin):
|
|
|
945
946
|
self.assertTrue(any(r.external_key == "library_admin" for r in a.roles))
|
|
946
947
|
|
|
947
948
|
|
|
949
|
+
@ddt
|
|
950
|
+
class TestGetVisibleRoleUserCounts(BaseRolesTestCase):
|
|
951
|
+
"""Tests for get_visible_role_user_counts, which backs the role catalog ``user_count``."""
|
|
952
|
+
|
|
953
|
+
_ASSIGNMENTS = [
|
|
954
|
+
# alice can view the team of lib:Org1:math_101 only
|
|
955
|
+
{"subject_name": "alice", "role_name": LIBRARY_ADMIN.external_key, "scope_name": "lib:Org1:math_101"},
|
|
956
|
+
# bob has the same role in two libraries
|
|
957
|
+
{"subject_name": "bob", "role_name": LIBRARY_AUTHOR.external_key, "scope_name": "lib:Org1:math_101"},
|
|
958
|
+
{"subject_name": "bob", "role_name": LIBRARY_AUTHOR.external_key, "scope_name": "lib:Org1:history_201"},
|
|
959
|
+
# carol is in a library alice cannot view
|
|
960
|
+
{"subject_name": "carol", "role_name": LIBRARY_AUTHOR.external_key, "scope_name": "lib:Org2:physics_401"},
|
|
961
|
+
# dave is inactive
|
|
962
|
+
{"subject_name": "dave", "role_name": LIBRARY_USER.external_key, "scope_name": "lib:Org1:math_101"},
|
|
963
|
+
# erin is in an org glob, which counts as the ``lib`` scope type
|
|
964
|
+
{"subject_name": "erin", "role_name": LIBRARY_USER.external_key, "scope_name": "lib:Org2:*"},
|
|
965
|
+
# frank is in a course
|
|
966
|
+
{
|
|
967
|
+
"subject_name": "frank",
|
|
968
|
+
"role_name": COURSE_STAFF.external_key,
|
|
969
|
+
"scope_name": "course-v1:Org1+CS101+2024",
|
|
970
|
+
},
|
|
971
|
+
]
|
|
972
|
+
|
|
973
|
+
@classmethod
|
|
974
|
+
def setUpTestData(cls):
|
|
975
|
+
super().setUpTestData()
|
|
976
|
+
User = get_user_model()
|
|
977
|
+
for username in ["alice", "bob", "carol", "erin", "frank", "nobody"]:
|
|
978
|
+
User.objects.create_user(username=username, email=f"{username}@example.com")
|
|
979
|
+
User.objects.create_user(username="dave", email="dave@example.com", is_active=False)
|
|
980
|
+
User.objects.create_user(username="staff_viewer", email="staff_viewer@example.com", is_staff=True)
|
|
981
|
+
|
|
982
|
+
@classmethod
|
|
983
|
+
def setUpClass(cls):
|
|
984
|
+
super().setUpClass()
|
|
985
|
+
# Assign as users (``user^`` subjects); the base helper assigns generic ``sub^`` subjects.
|
|
986
|
+
for assignment in cls._ASSIGNMENTS:
|
|
987
|
+
assign_role_to_user_in_scope(assignment["subject_name"], assignment["role_name"], assignment["scope_name"])
|
|
988
|
+
|
|
989
|
+
def test_counts_distinct_active_users_per_role(self):
|
|
990
|
+
"""Without a viewer, every active user counts once per role.
|
|
991
|
+
|
|
992
|
+
Expected result:
|
|
993
|
+
- bob counts once although he has the role in two libraries
|
|
994
|
+
- dave, who is inactive, is not counted
|
|
995
|
+
- erin, in an org glob, counts as a library user
|
|
996
|
+
- frank's course assignment is left out of the library counts
|
|
997
|
+
"""
|
|
998
|
+
result = get_visible_role_user_counts(["lib"])
|
|
999
|
+
|
|
1000
|
+
self.assertEqual(
|
|
1001
|
+
result,
|
|
1002
|
+
{
|
|
1003
|
+
LIBRARY_ADMIN.external_key: 1,
|
|
1004
|
+
LIBRARY_AUTHOR.external_key: 2,
|
|
1005
|
+
LIBRARY_USER.external_key: 1,
|
|
1006
|
+
},
|
|
1007
|
+
)
|
|
1008
|
+
|
|
1009
|
+
@data(
|
|
1010
|
+
(["course-v1"], {COURSE_STAFF.external_key: 1}),
|
|
1011
|
+
(
|
|
1012
|
+
["course-v1", "lib"],
|
|
1013
|
+
{
|
|
1014
|
+
LIBRARY_ADMIN.external_key: 1,
|
|
1015
|
+
LIBRARY_AUTHOR.external_key: 2,
|
|
1016
|
+
LIBRARY_USER.external_key: 1,
|
|
1017
|
+
COURSE_STAFF.external_key: 1,
|
|
1018
|
+
},
|
|
1019
|
+
),
|
|
1020
|
+
(["unknown"], {}),
|
|
1021
|
+
)
|
|
1022
|
+
@unpack
|
|
1023
|
+
def test_counts_only_requested_scope_types(self, scope_types: list[str], expected: dict[str, int]):
|
|
1024
|
+
"""Only assignments in the requested scope types count.
|
|
1025
|
+
|
|
1026
|
+
Expected result:
|
|
1027
|
+
- The counts match the assignments of the requested scope types
|
|
1028
|
+
"""
|
|
1029
|
+
self.assertEqual(get_visible_role_user_counts(scope_types), expected)
|
|
1030
|
+
|
|
1031
|
+
def test_viewer_only_counts_scopes_it_can_view(self):
|
|
1032
|
+
"""A viewer only counts the assignments in scopes where it can view the team.
|
|
1033
|
+
|
|
1034
|
+
Expected result:
|
|
1035
|
+
- alice counts herself and bob in lib:Org1:math_101, but not carol, erin or bob's other library
|
|
1036
|
+
"""
|
|
1037
|
+
result = get_visible_role_user_counts(["lib"], allowed_for_user_external_key="alice")
|
|
1038
|
+
|
|
1039
|
+
self.assertEqual(result, {LIBRARY_ADMIN.external_key: 1, LIBRARY_AUTHOR.external_key: 1})
|
|
1040
|
+
|
|
1041
|
+
def test_staff_viewer_counts_everything(self):
|
|
1042
|
+
"""A staff viewer counts every assignment, as it can view every team.
|
|
1043
|
+
|
|
1044
|
+
Expected result:
|
|
1045
|
+
- The counts are the same as without a viewer
|
|
1046
|
+
"""
|
|
1047
|
+
self.assertEqual(
|
|
1048
|
+
get_visible_role_user_counts(["lib"], allowed_for_user_external_key="staff_viewer"),
|
|
1049
|
+
get_visible_role_user_counts(["lib"]),
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1052
|
+
def test_viewer_without_roles_counts_nothing(self):
|
|
1053
|
+
"""A viewer without role assignments cannot view any team.
|
|
1054
|
+
|
|
1055
|
+
Expected result:
|
|
1056
|
+
- No role is counted
|
|
1057
|
+
"""
|
|
1058
|
+
self.assertEqual(get_visible_role_user_counts(["lib"], allowed_for_user_external_key="nobody"), {})
|
|
1059
|
+
|
|
1060
|
+
|
|
948
1061
|
class TestExpandScopesWithAncestors(UserAssignmentsSetupMixin):
|
|
949
1062
|
"""Unit tests for ScopeData.expand_keys_with_ancestors."""
|
|
950
1063
|
|