Skip to content

feat(authz): add the AuthZ catalog feature - #262

Merged
dcoa merged 7 commits into
masterfrom
dcoa/catalog-1-feature
Nov 11, 2026
Merged

dcoa merged 7 commits into
masterfrom
dcoa/catalog-1-feature

Conversation

@dcoa

@dcoa dcoa commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add a shared AuthZ catalog feature that prepares the Admin Console to consume backend-defined roles, permissions, and categories.

How it works:

  • Validate view-team permissions
  • Fetch the catalog for viewable scope types
  • Merge all role pages
  • Expose a filtered catalog for each scope type

The feature provides:

  • useAuthzCatalog, with shared caching and stable per-scope catalogs.
  • Scope filtering and role ordering by descending permission count.
  • CatalogIcon, which loads Paragon icons by name and preserves spacing when an icon is loading or unknown.
  • Shared types, test helpers, and an architecture decision record.

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 lint

Verify that the catalog tests cover:

  • Fetching both supported scope types when the user can view both teams.
  • Fetching only the library catalog when only library-team access is allowed.
  • Waiting for permission validation and skipping the catalog request when neither scope type is viewable.
  • Combining paginated roles in page order.
  • Filtering roles, permissions, and categories by scope type.
  • Sorting roles by permission count while preserving catalog order for ties.
  • Rendering valid icons, preserving an empty placeholder for unknown names, and rendering nothing for a null icon.

Run the full regression suite:

npm test -- --watch=false --runInBand

No 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

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Oct 15, 2026
@openedx-webhooks

openedx-webhooks commented Oct 15, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @dcoa!

This repository is currently maintained by @openedx/committers-frontend.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (117ec95) to head (18d6657).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dcoa
dcoa added this pull request to stack #265 October 15, 2026 03:17
@dcoa
dcoa force-pushed the dcoa/catalog-1-feature branch 3 times, most recently from f550481 to d355afd Compare October 15, 2026 07:06
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Oct 22, 2026
@dcoa dcoa self-assigned this Oct 28, 2026
@dcoa
dcoa marked this pull request as ready for review October 28, 2026 05:33
@dcoa
dcoa requested review from BryanttV, arbrandes, bra-i-am, jacobo-dominguez-wgu and rodmgwgu and removed request for arbrandes October 28, 2026 06:11
@dcoa
dcoa force-pushed the dcoa/catalog-1-feature branch from 7eb0833 to d9cd96d Compare October 28, 2026 06:16
Comment thread docs/decisions/0004-authz-catalog.rst Resolved
* 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) => {

@dcoa dcoa Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


const NO_SCOPE_TYPES: string[] = [];

const VIEW_TEAM_PERMISSIONS = Object.fromEntries(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bare true for a parameter named featureEnabled deserves a one-line comment or a constant with a self-descriptive name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in the stacked PRs

@jacobo-dominguez-wgu jacobo-dominguez-wgu left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, good work! I will approve it once I test the following prs on the stack.

@mphilbrick211 mphilbrick211 moved this from Waiting on Author to In Eng Review in Contributions Nov 4, 2026

@bra-i-am bra-i-am left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working as expected!!!

image

I saw that #269 already addresses some things I had in mind, and I have no further comments for this PR

dcoa and others added 6 commits November 9, 2026 13:35
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]>
@dcoa
dcoa force-pushed the dcoa/catalog-1-feature branch from 8cb1f97 to c62ea0a Compare November 9, 2026 02:35

@rodmgwgu rodmgwgu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/decisions/0004-authz-catalog.rst Outdated

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``.

@rodmgwgu rodmgwgu Nov 9, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/decisions/0004-authz-catalog.rst Outdated

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.**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already contemplated in the evolution part

Comment thread docs/decisions/0004-authz-catalog.rst Outdated

* 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I's not clear to me what are groups in this context, aren't these the categories we already have?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, can you add something that clarifies this to the document please?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworded to make it clear

@dcoa
dcoa requested a review from rodmgwgu November 10, 2026 02:54

@rodmgwgu rodmgwgu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM!

@dcoa
dcoa merged commit 98df8ae into master Nov 11, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Nov 11, 2026
@dcoa
dcoa deleted the dcoa/catalog-1-feature branch November 11, 2026 22:12
@openedx-semantic-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-alpha.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U released on @latest

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants