Repository navigation
feat: add the endpoints to read and remove custom roles - #656
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. |
fef600f to
e5f125e
Compare
e5f125e to
f1d9fbc
Compare
2785c0c to
6e0f0d6
Compare
845a6f2 to
b2a13a2
Compare
b2a13a2 to
5e43abf
Compare
GET /api/authz/v1/roles/<role_id>/ returns one role, static or custom, in the format of the role list (ADR 0036). The caller needs the permission to list roles of one of the role's resource types; staff and superusers always pass. DELETE /api/authz/v1/roles/<role_id>/ removes a custom role and is limited to staff and superusers. A role with assignments needs assignments=revoke, otherwise it returns 409 and removes nothing. Static roles return 400, and unknown or removed roles return 404 on both endpoints. Closes #581 Co-authored-by: Kiro <noreply@kiro.dev>
5e43abf to
fbff17a
Compare
Closes #581
Problem
The Administrative Console can't open a role's detail view or remove a custom role.
api.remove_custom_rolefrom #644 has no REST endpoint, and there is no endpoint that returns one role.Approach
GETandDELETEtoRoleDetailViewat/api/authz/v1/roles/<role_id>/, as ADR 0036 defines them.GETreturns the role, static or custom, in the format of a role list item, throughget_role_entry. A non-staff caller needs the permission ADR 0028 requires to list roles of one of the role's resource types (courses.view_course_teamorcontent_libraries.view_library_team). The newRoleScopeTypePermissionchecks this against the role in the URL. An unknown role is left to the view, so it returns 404 for every caller.DELETEis limited to staff and superusers throughPrivilegedWritePermissionand callsapi.remove_custom_role. A role with assignments needsassignments=revoke, or the request returns 409 and removes nothing. Any other value returns 400, an empty value counts as not sent. Static roles return 400, and unknown or removed roles return 404.Manual testing instructions
As a staff user in the LMS, with a custom library role
custom_designerassigned to one user in a library:/api/authz/v1/roles/custom_designer/. It returns 200 withuser_count1./api/authz/v1/roles/custom_designer/. It returns 409 and the role is still listed./api/authz/v1/roles/custom_designer/?assignments=revoke. It returns 204, the user loses the role's access, and GET returns 404./api/authz/v1/roles/library_author/. It returns 400.Unit tests:
pytest src/openedx_authz/tests/rest_api/test_views.py -k "TestRoleDetailViewRead or TestRoleDetailViewRemove".Rollback plan
Revert this PR. No migration. Roles removed through the endpoint stay removed.
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: