Repository navigation
feat: add the endpoint to edit custom roles - #649
Conversation
|
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. |
4848314 to
65661f4
Compare
65661f4 to
21df998
Compare
21df998 to
b3f6bdd
Compare
b3f6bdd to
2525d5e
Compare
2525d5e to
e2ace28
Compare
e2ace28 to
157dc9e
Compare
157dc9e to
22dc34a
Compare
256d31b to
aed6933
Compare
aed6933 to
94c7848
Compare
PATCH /api/authz/v1/roles/<role_id>/ changes the description or the permissions of a custom role (ADR 0036). Only staff and superusers can edit roles. The name and resource type cannot change, so sending them returns 400, as does editing a static role. A role that does not exist or was removed returns 404. Permission dependency checks wait for dependencies to be stored in the schema (#560). Co-authored-by: Kiro <noreply@kiro.dev>
94c7848 to
2dbae01
Compare
BryanttV
left a comment
There was a problem hiding this comment.
Thanks for addressing my comments, LGTM!
Closes #590
Problem
The Administrative Console can't edit custom roles.
api.update_custom_rolefrom #644 has no REST endpoint.Approach
PATCH /api/authz/v1/roles/<role_id>/in a newRoleDetailView, as ADR 0036 defines it. The request takesdescription,permissions, or both, and callsapi.update_custom_role.permissionsreplaces the full list.PrivilegedWritePermission.UpdateCustomRoleSerializerkeeps only the fields that were sent and rejectsdisplay_nameandscope_types, which can't change after creation. The other rules stay in the API. Editing a static role returns 400, and a role that doesn't exist or was removed returns 404.user_countthe caller can view.get_role_entrybuilds it, and the create endpoint now uses it too, so both write paths respond the same way.CustomRoleViewTestMixin.Manual testing instructions
As a staff user in the LMS, with a custom library role
custom_designerthat grantscontent_libraries.view_library:/api/authz/v1/roles/custom_designer/with{"description": "Edits libraries"}. It returns 200 with the new description and a laterupdated_at.{"permissions": ["content_libraries.edit_library_content"]}. It returns 200, and a user with the role in a library can now edit content but no longer hasview_library.{"display_name": "Other"}. It returns 400./api/authz/v1/roles/library_author/with{"description": "x"}. It returns 400.Unit tests:
pytest src/openedx_authz/tests/rest_api/test_views.py -k TestRoleDetailViewUpdate.Rollback plan
Revert this PR. No migration. Edits made through the endpoint stay.
Retro compatibility
No existing endpoint changes.
AI Usage
Kiro assisted with the implementation and review, with human guidance on the decisions and validation against ADR 0036.
Merge checklist: