Skip to content

feat(authz): show a user's role permissions from the catalog - #266

Merged
dcoa merged 1 commit into
dcoa/catalog-3-permissions-matrixfrom
dcoa/catalog-4-user-permissions
Nov 11, 2026
Merged

dcoa merged 1 commit into
dcoa/catalog-3-permissions-matrixfrom
dcoa/catalog-4-user-permissions

Conversation

@dcoa

@dcoa dcoa commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary
Build a user’s role permission breakdown from the AuthZ catalog, using the scope type of the assignment.

How it works:

  • Resolve its scope type
  • Find the catalog permissions granted by its role
  • Group by category
  • Render names, icons, and descriptions

What changes:

  • Use catalog metadata instead of hardcoded permission definitions.
  • Keep scope classification centralized through getScopeContextType.
  • Reuse the matrix builder and category popovers introduced in [feat(authz): build the roles permission matrix from the catalog #264](https://github.com/openedx/frontend-app-- admin-console/pull/264).
  • Group uncategorized permissions under Other.
  • Preserve the inline layout for up to three categories and the two-column layout for larger breakdowns.
  • Show the permission count as plain text when the catalog does not describe the role for that scope type.
  • Remove obsolete permission-label helpers, icon mappings, and types.

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.

image

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

With the catalog backend available:

  1. Open a user’s role assignments and expand the permissions for a course or library role.
  2. Verify that only permissions granted by that role appear, grouped by catalog category.
  3. Check category popovers for names and descriptions.
  4. Verify both layouts using roles spanning up to three categories and more than three.
  5. Confirm that an unknown role’s permission count remains plain text and Django-managed roles retain their existing descriptions.

AI disclosure

Code assisted by Claude

@dcoa
dcoa added this pull request to stack #265 October 15, 2026 03:19
@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.90%. Comparing base (ee35f5f) to head (a490953).

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.
📢 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 force-pushed the dcoa/catalog-4-user-permissions branch from 22e5d97 to 31a384a Compare October 15, 2026 07:06
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Oct 22, 2026
@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from 31a384a to 6aaca49 Compare October 28, 2026 11:27
@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from 6aaca49 to fface55 Compare October 28, 2026 12:24
@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from fface55 to eb34b75 Compare October 28, 2026 12:39
@dcoa
dcoa marked this pull request as ready for review October 29, 2026 02:47
@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from eb34b75 to 6223cf9 Compare October 29, 2026 09:00
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready for Review in Contributions Nov 4, 2026

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

Tested locally and works well, just some minor comments.

Comment thread src/authz-module/components/messages.ts Outdated
'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',

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.

Suggested change
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',

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.

done in #264 (comment)

// Category of the permissions the catalog sends without one.
const OTHER_CATEGORY_ID = 'other';

const catalogScopeTypes = {

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

@dcoa dcoa Nov 5, 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.

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.

@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from 6223cf9 to 73d24ec Compare November 5, 2026 02:26

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

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.
Library User showing 12 granted permissions but three entries in the expanded breakdown

@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from 73d24ec to 692d388 Compare November 9, 2026 02:35
@dcoa

dcoa commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Permission counts differ from the expanded breakdown

I could not reproduce your situation about the mismatch between the APIs permission count in my local environment.

image

It its possible that Casbin and the catalog are out of sync. Running load_authz_schema should reconcile both.

c.c @BryanttV

@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from 692d388 to 61b1a7a Compare November 9, 2026 05:40
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]>
@dcoa
dcoa force-pushed the dcoa/catalog-4-user-permissions branch from 61b1a7a to a490953 Compare November 10, 2026 02:56

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

LGTM!

@dcoa
dcoa merged commit 161a117 into master Nov 11, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions Nov 11, 2026
@dcoa
dcoa deleted the dcoa/catalog-4-user-permissions 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.

5 participants