Repository navigation
Conversation
…tom role POST /api/authz/v1/roles/ and PATCH /api/authz/v1/roles/<role_id>/ now reject a permission set that leaves out a direct or indirect dependency of another permission in the set, with 400 and missing_dependencies (ADR 0036 section 7). Hidden permissions an edit keeps count as granted, and their own dependencies are not checked. Closes #674
|
Thanks for the pull request, @rodmgwgu! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Closes #674
Problem
ADR 0036 section 7 requires the create and update custom role endpoints to reject a permission set that leaves out a dependency, but #647 and #649 shipped without the check because dependencies were not stored yet. Since #657 they are, so a client can still save a role that grants, for example,
edit_library_contentwithoutview_library.Approach
create_custom_roleandupdate_custom_rolecheck the set with the existingmissing_dependencieshelper and the stored dependency map, after the other permission checks and before any write. Both endpoints get the check from there.MissingPermissionDependenciesError, a subclass ofInvalidCustomRoleError. The server does not add dependencies.POST /api/authz/v1/roles/andPATCH /api/authz/v1/roles/<role_id>/return 400 withmessageandmissing_dependencies, which maps each permission to the sorted IDs it is missing, so the admin console can point at the permissions to add without parsing text.g2rows still grant the dependencies.Manual testing instructions
As a staff user in the LMS:
/api/authz/v1/roles/with{"display_name": "Library Cleaner", "scope_types": ["lib"], "permissions": ["content_libraries.delete_library"]}. It returns 400 withmissing_dependencieslistingcontent_libraries.edit_library_contentandcontent_libraries.view_library, and no role is created."permissions": ["content_libraries.delete_library", "content_libraries.edit_library_content", "content_libraries.view_library"]. It returns 201./api/authz/v1/roles/custom_library_cleaner/with{"permissions": ["content_libraries.edit_library_content"]}. It returns 400 listingcontent_libraries.view_library, and the role keeps its three permissions.Unit tests:
pytest src/openedx_authz/tests/api/test_custom_roles.py src/openedx_authz/tests/rest_api/test_views.py -k "dependenc or hidden".Rollback plan
Revert this PR. No migration and no stored data.
Retro compatibility
Create and update now reject permission sets they accepted before. Both endpoints are still unreleased, so no released client depends on the old behavior. Roles saved before this change without their dependencies are not changed; their next permissions edit must send a complete set.
AI Usage
🤖 This change was made with assistance from Kiro, with human guidance on the decisions and validation against ADR 0036.
Merge checklist:
main, not stacked.