Repository navigation
feat(authz): show a user's role permissions from the catalog - #266
Conversation
|
Thanks for the pull request, @dcoa! 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dcoa/catalog-3-permissions-matrix #266 +/- ##
=====================================================================
+ Coverage 98.78% 98.90% +0.12%
=====================================================================
Files 84 81 -3
Lines 1483 1465 -18
Branches 485 477 -8
=====================================================================
- Hits 1465 1449 -16
+ Misses 18 16 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
22e5d97 to
31a384a
Compare
31a384a to
6aaca49
Compare
6aaca49 to
fface55
Compare
fface55 to
eb34b75
Compare
eb34b75 to
6223cf9
Compare
jacobo-dominguez-wgu
left a comment
There was a problem hiding this comment.
Tested locally and works well, just some minor comments.
| 'authz.tabs.permissionsRoles.category.other': { | ||
| id: 'authz.tabs.permissionsRoles.category.other', | ||
| defaultMessage: 'Other', | ||
| description: 'Libraries AuthZ name of the category that groups the permissions without a category', |
There was a problem hiding this comment.
| description: 'Libraries AuthZ name of the category that groups the permissions without a category', | |
| description: 'AuthZ name of the category that groups the permissions without a category', |
| // Category of the permissions the catalog sends without one. | ||
| const OTHER_CATEGORY_ID = 'other'; | ||
|
|
||
| const catalogScopeTypes = { |
There was a problem hiding this comment.
The scope-to-catalog mapping is written two ways. TableCells.tsx uses a ternary on CONTEXT_TYPES.LIBRARY, while UserPermissions.tsx uses a catalogScopeTypes map. One helper in constants.ts (for example getScopeCatalogType(scope)) would keep this in one place, which matches the PR's own goal of keeping scope classification centralized
There was a problem hiding this comment.
it was done in 07c17e2
Stack 7 (refactor(authz): remove the hardcoded catalog) adds getScopeType(scope) to constants.ts and switches both TableCells and UserPermissions to it, removing the ternary and the catalogScopeTypes map.
6223cf9 to
73d24ec
Compare
bra-i-am
left a comment
There was a problem hiding this comment.
looks good!! I see that #269 already addresses the scope-classification duplication discussed here.
I have no additional blocking code concerns and I'll approve, but I saw a thing I think is worth tracking
Permission counts differ from the expanded breakdown
The assignment API’s permission_count and the catalog permissions (roles/?scope_types=course-v1%2Clib) displayed in the expanded breakdown are different:
| Role | Assignment permission_count | Catalog permissions |
|---|---|---|
| Course Staff | 31 | 31 |
| Library Author | 34 | 9 |
| Library Contributor | 16 | 8 |
| Library User | 12 | 3 |
For example, Library User shows “12 granted”, but expanding it displays three permissions: View Library, Reuse Library Content, and View Library Team.

73d24ec to
692d388
Compare
I could not reproduce your situation about the mismatch between the APIs permission count in my local environment.
It its possible that Casbin and the catalog are out of sync. Running c.c @BryanttV |
692d388 to
61b1a7a
Compare
The user permissions column groups the role permissions by catalog category, for the scope type of the assignment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
61b1a7a to
a490953
Compare
|
🎉 This PR is included in version 1.0.0-alpha.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |

Summary
Build a user’s role permission breakdown from the AuthZ catalog, using the scope type of the assignment.
How it works:
What changes:
getScopeContextType.Affects expanded role permission breakdowns and their availability while the catalog loads. Depends on the preceding catalog and matrix changes.
Evidence
Before::The expanded permission breakdown uses frontend-maintained course and library metadata.
After: It displays the permissions granted by the assignment’s role in its scope-specific catalog. A role from another scope type cannot supply the breakdown.
Tests cover category grouping, scope isolation, unavailable catalogs, unknown roles, empty permissions, Django-managed roles, and both layouts.
Test instructions
npm test -- --watch=false --runInBand \ src/authz-module/components/UserPermissions.test.tsx \ src/authz-module/components/RenderPermissionColumn.test.tsx \ src/authz-module/components/RenderPermissionInline.test.tsx \ src/authz-module/components/TableCells.test.tsx \ src/authz-module/audit-user/index.test.tsxWith the catalog backend available:
AI disclosure
Code assisted by Claude