Skip to content

feat(authz): use catalog roles for assignment filters and scope types for scope filtering - #268

Merged
dcoa merged 3 commits into
dcoa/catalog-5-assign-wizardfrom
dcoa/catalog-6-team-tables
Nov 11, 2026
Merged

dcoa merged 3 commits into
dcoa/catalog-5-assign-wizardfrom
dcoa/catalog-6-team-tables

Conversation

@dcoa

@dcoa dcoa commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Use catalog library roles for the default role restriction in the Team Members table and Audit User page. In this way all the API share the same glossary.

  • Replace the hardcoded LIBRARY_ROLE_KEYS list with catalog role IDs.
  • Allow backend-defined library roles to participate in table filtering without updating a frontend list.
  • Update the Scopes filter to send scope_type=lib instead of the deprecated library alias.
  • Remove the unused hardcoded role-key export and update the related tests.

Note

Note on the library-only roles filter. When the user can't view course teams, the team tables send roles=<the catalog's library roles>, as on master (#176). This PR keeps that behavior and only takes the roles from the catalog, waiting for it to load so no request goes out without the filter.

The filter looks redundant with the backend. /users/ and /users/<username>/assignments/ already return only the assignments the caller can see (filter_role_assignments_visible_to_subject checks the scope's admin-view permission, view_course_team for courses). A user without course-view permission gets no course assignments either way. We probably should evaluate if the validation is still needed.

Affects default role restrictions in the team and user assignment tables, plus scope-filter requests. Depends on the preceding catalog stack, including #267.

Evidence

Before: Library-only table queries use a frontend-maintained role list, and scope filtering relies on the deprecated library alias.

After: Both tables derive their default library-role filter from the catalog, and the Scopes filter uses SCOPE_TYPES.LIBRARY (lib).

Tests cover catalog-based role restrictions in both tables, library-only scope filtering, and serialization of scope_type=lib.

Test instructions

npm test -- --watch=false --runInBand \
  src/authz-module/team-members/TeamMembersTable.test.tsx \
  src/authz-module/audit-user/index.test.tsx \
  src/authz-module/components/TableControlBar/ScopesFilter.test.tsx \
  src/authz-module/data/api.test.tsx

With a user who can view library teams but cannot view course teams:

  1. Open Team Members and verify the request’s roles parameter matches the library role IDs returned by the catalog.
  2. Open a user’s audit page and verify the same default restriction.
  3. Apply an explicit role filter and confirm it is preserved.
  4. Open the Scopes filter and confirm requests use scope_type=lib.

Repeat with course-team access and confirm the default library-role restriction is not applied.

Partially closes openedx/openedx-authz#535

AI disclosure

Assisted by Claude

@dcoa
dcoa added this pull request to stack #265 October 15, 2026 03:26
@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.98%. Comparing base (bf39b88) to head (b438b0a).

Additional details and impacted files
@@                       Coverage Diff                        @@
##           dcoa/catalog-5-assign-wizard     #268      +/-   ##
================================================================
+ Coverage                         98.90%   98.98%   +0.07%     
================================================================
  Files                                81       81              
  Lines                              1465     1474       +9     
  Branches                            451      489      +38     
================================================================
+ Hits                               1449     1459      +10     
+ Misses                               16       15       -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 force-pushed the dcoa/catalog-6-team-tables branch 2 times, most recently from 569b4bd to 42f8f44 Compare October 15, 2026 08:50
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Oct 22, 2026
@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from 42f8f44 to 29540e3 Compare October 29, 2026 06:47
@dcoa dcoa changed the title feat(authz): restrict the team tables to the catalog library roles feat(authz): use catalog roles in team tables and migrate scope filter to use scope_types Oct 29, 2026
@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from 29540e3 to 844b963 Compare October 29, 2026 08:09
@dcoa dcoa changed the title feat(authz): use catalog roles in team tables and migrate scope filter to use scope_types feat(authz): use catalog roles for assigngments request filter and migrate scope filter to use scope_types Oct 29, 2026
@dcoa dcoa changed the title feat(authz): use catalog roles for assigngments request filter and migrate scope filter to use scope_types feat(authz): use catalog roles for assignment filters and scope types for scope filtering Oct 29, 2026
@dcoa
dcoa marked this pull request as ready for review October 29, 2026 08:25
@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from 844b963 to df24f15 Compare October 29, 2026 08:29
@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from df24f15 to 1f39bf9 Compare October 29, 2026 09:00
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready for Review in Contributions Nov 4, 2026
@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from 1f39bf9 to a30148b Compare November 5, 2026 02:27

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

it working as expected!!


nit: when a user without permissions goes to http://apps.local.openedx.io:2025/admin-console/authz, they see a 403 error

Image

but if the user goes to http://apps.local.openedx.io:2025/admin-console/authz/user/user, they'll see an empty table. I think this could also be a 403

Image

Finally, if a user with permissions goes there, they'll see the same empty table; I think this will be better if it showed a proper UI like

Image

@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from a30148b to cb5881f Compare November 9, 2026 03:06
@dcoa

dcoa commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @bra-i-am, that is out of the scope of this PR

but if the user goes to http://apps.local.openedx.io:2025/admin-console/authz/user/user, they'll see an empty table. I think this could also be a 403

This is something that will be solved when we refactor the router as proposed here #247. But as I mentioned there, all that will happen after the catalog is merged.

Finally, if a user with permissions goes there, they'll see the same empty table; I think this will be better if it showed a proper UI like

That needs validation for the Product and UX/UI Team. I suggest create a issue and tag them.

@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from cb5881f to 468ee04 Compare November 9, 2026 05:40
dcoa and others added 2 commits November 10, 2026 13:56
The team members table and the audit user page take the library roles from the catalog instead of a hardcoded list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GET /api/authz/v1/scopes/ now expects scope_type=course-v1 or lib, and
only accepts course and library as deprecated aliases. The scopes filter
of the team tables still sent scope_type=library to users who can't view
courses; it now sends the library scope type (lib), so the console no
longer relies on the aliases and they can be removed from the API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dcoa
dcoa force-pushed the dcoa/catalog-6-team-tables branch from 468ee04 to ceb33f2 Compare November 10, 2026 02:56

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

Two nonblocking consistency suggestions:

  1. The request uses SCOPE_TYPES.LIBRARY, but filtering, icons, and grouping still repeat startsWith('lib'). Could be used the existing scope classifier and getScopeResourceIcon to keep this consistent

  2. Replace the old course/library examples with course-v1/lib and their SCOPE_TYPES constants. Also correct org to orgs

Comment thread src/authz-module/data/hooks.ts Outdated

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
* - `scopeType` — filter by scope type (`SCOPE_TYPES.COURSE` / `course-v1` or `SCOPE_TYPES.LIBRARY` / `lib`)

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.

Solved here b438b0a

Comment on lines 32 to 36
.filter((scope) => scope.externalKey?.startsWith('lib') || isCourseEnabled(scope.externalKey))
.map((scope) => {
const scopeIcon = scope.externalKey?.startsWith('lib') ? RESOURCE_ICONS.LIBRARY : RESOURCE_ICONS.COURSE;
let groupName = formatMessage(messages['authz.team.members.table.group.courses']);
if (scope.externalKey?.startsWith('lib')) {

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
.filter((scope) => getScopeContextType(scope.externalKey) === CONTEXT_TYPES.LIBRARY || isCourseEnabled(scope.externalKey))
.map((scope) => {
const scopeIcon = getScopeResourceIcon(scope.externalKey);
let groupName = formatMessage(messages['authz.team.members.table.group.courses']);
if (getScopeContextType(scope.externalKey) === CONTEXT_TYPES.LIBRARY) {

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

Thank you, I overlooked that. I'll make the change in PR #269 as getScopeContextType changes, so I make a unique update.

@dcoa
dcoa merged commit 8823aa4 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-6-team-tables 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.

Migrate Admin Console to the new scope_type values (course-v1/lib)

5 participants