Repository navigation
feat(authz): add the AuthZ catalog feature - #262
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 @@
## master #262 +/- ##
==========================================
+ Coverage 98.57% 98.62% +0.04%
==========================================
Files 79 83 +4
Lines 1406 1452 +46
Branches 477 456 -21
==========================================
+ Hits 1386 1432 +46
Misses 19 19
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f550481 to
d355afd
Compare
7eb0833 to
d9cd96d
Compare
| * While the icon loads, and when the name is unknown, it renders an empty icon of the same size, so | ||
| * the layout doesn't shift. When the catalog sends no icon, it renders nothing. | ||
| */ | ||
| const CatalogIcon = ({ name, ...iconProps }: CatalogIconProps) => { |
There was a problem hiding this comment.
Note
There was a recent review at the backend openedx/openedx-authz#537 (comment) and we are going to use a set of icon names agreed between the front and the backend, so at the front side we will have a map of icons.
We could still review this and subsequent PRs, understanding that once the set of icons are defined it only affects this file and not consumers.
629b048 to
8cb1f97
Compare
|
|
||
| const NO_SCOPE_TYPES: string[] = []; | ||
|
|
||
| const VIEW_TEAM_PERMISSIONS = Object.fromEntries( |
There was a problem hiding this comment.
nit: There is already a VIEW_TEAM_PERMISSIONS defined in https://github.com/openedx/frontend-app-admin-console/blob/master/src/authz-module/roles-permissions/index.ts, two copies of a permission string is exactly the drift the ADR is arguing against, it is the same name in the same module but the object shape is different, maybe a rename would be good.
There was a problem hiding this comment.
The ADR focuses on avoiding a hardcoded copy of the backend’s catalog metadata, but I agree the duplicate definition is confusing.
I addressed this in PR #269, commit 3683d22 by migrating useViewTeamPermissions to the frontend-base hook. Both hooks now import the same VIEW_TEAM_PERMISSIONS map, giving all consumers one shared shape and permission query.
| * ``` | ||
| */ | ||
| export const useAuthzCatalog = () => { | ||
| const permissions = usePermissions(VIEW_TEAM_PERMISSIONS, true); |
There was a problem hiding this comment.
The bare true for a parameter named featureEnabled deserves a one-line comment or a constant with a self-descriptive name.
There was a problem hiding this comment.
PR #269, commit 3683d22 also covers the comment
| export { useAuthzCatalog } from './data/hooks'; | ||
| export { default as CatalogIcon } from './CatalogIcon'; | ||
| export type { | ||
| AuthzCatalog, Category, CategoryPermissions, Permission, Role, ScopeCatalog, |
There was a problem hiding this comment.
Note: CategoryPermissions is defined and exported from the barrel but used nowhere, I am guessing it will be used in the rest of the stacked prs.
There was a problem hiding this comment.
It is used in the stacked PRs
Fetch the roles, permissions and categories catalog of the scope types the user can view, slice it by scope type, order its roles by permission count, and render its icons by name with CatalogIcon. Nothing consumes it yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
8cb1f97 to
c62ea0a
Compare
rodmgwgu
left a comment
There was a problem hiding this comment.
Thanks for this work, about the ADR, it's looking good but I aded some comments mostly related to the Custom Roles work we are starting.
|
|
||
| Pages are not loaded on demand, because the current UI displays all the roles of a scope type at once: the matrix shows each role as a column, and the roles filter and the wizard list every role the user can choose. This design fits the limited number of roles per scope type and the scope types known today. | ||
|
|
||
| The catalog comes from the authz schema and does not change while the app runs, so the query has an infinite ``staleTime``. |
There was a problem hiding this comment.
This won't be true once Custom Roles are implemented, which is now in progress and planned for Willow. We should lower the staleTime or have a way to force a refresh.
There was a problem hiding this comment.
I added a helper so other parts of the application can invalidate the catalog query. The hook already exposes React Query’s refetch function for manual refreshes.
I also set staleTime to 30 minutes.
The ADR now reflects that.
|
|
||
| The catalog comes from the authz schema and does not change while the app runs, so the query has an infinite ``staleTime``. | ||
|
|
||
| **5. Screens consume one scope type at a time.** |
There was a problem hiding this comment.
This won't always be true when Custom Roles are implemented, see the design here: https://www.figma.com/design/xnmQJq1cTRVqNrs31R8zDM/AuthZ---v2?node-id=40000174-2&p=f&t=1U8cVDehj9iDxFQo-0
There was a problem hiding this comment.
This is already contemplated in the evolution part
|
|
||
| * the view-team action of each scope type, used to build the request; | ||
| * ``SCOPE_TYPES`` and their display order; | ||
| * the tab labels, filter group names and group icons; |
There was a problem hiding this comment.
I's not clear to me what are groups in this context, aren't these the categories we already have?
There was a problem hiding this comment.
Yeah the wording is not clear but it is more a reference to the scope type metadata, the frontend still owns what scopes are available (libraries and courses) and their displayed name and icon.
There was a problem hiding this comment.
Understood, can you add something that clarifies this to the document please?
There was a problem hiding this comment.
I reworded to make it clear
|
🎉 This PR is included in version 1.0.0-alpha.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |

Summary
Add a shared AuthZ catalog feature that prepares the Admin Console to consume backend-defined roles, permissions, and categories.
How it works:
The feature provides:
useAuthzCatalog, with shared caching and stable per-scope catalogs.CatalogIcon, which loads Paragon icons by name and preserves spacing when an icon is loading or unknown.This PR introduces the catalog infrastructure only. Existing screens do not consume it yet.
Depends on openedx/openedx-authz#510, available in
openedx-authz==2.0.0.Evidence
Before: Roles, permissions, and categories are hardcoded in the frontend.
After: A reusable catalog module can retrieve these definitions from the backend for future screen migrations.
Added tests cover permission-based fetching, pagination, scope filtering, stable catalog references, role ordering, and icon rendering.
Test instructions
From the PR branch, install dependencies and run:
npm ci npm test -- --watch=false --runInBand src/authz-module/catalog npm run types npm run lintVerify that the catalog tests cover:
Run the full regression suite:
npm test -- --watch=false --runInBandNo visible UI change is expected because screen integration will follow in subsequent PRs. If you want to try the integration in a small component test #263 or if you want to test the full implementation check #270
AI disclosure
Code assisted by Claude