Repository navigation
feat(authz): use catalog roles for assignment filters and scope types for scope filtering - #268
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-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. 🚀 New features to boost your workflow:
|
569b4bd to
42f8f44
Compare
42f8f44 to
29540e3
Compare
29540e3 to
844b963
Compare
844b963 to
df24f15
Compare
df24f15 to
1f39bf9
Compare
1f39bf9 to
a30148b
Compare
bra-i-am
left a comment
There was a problem hiding this comment.
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
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
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
a30148b to
cb5881f
Compare
|
Thanks @bra-i-am, that is out of the scope of this PR
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.
That needs validation for the Product and UX/UI Team. I suggest create a issue and tag them. |
cb5881f to
468ee04
Compare
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]>
468ee04 to
ceb33f2
Compare
bra-i-am
left a comment
There was a problem hiding this comment.
Two nonblocking consistency suggestions:
-
The request uses
SCOPE_TYPES.LIBRARY, but filtering, icons, and grouping still repeatstartsWith('lib'). Could be used the existing scope classifier andgetScopeResourceIconto keep this consistent -
Replace the old
course/libraryexamples withcourse-v1/liband theirSCOPE_TYPESconstants. Also correctorgtoorgs
There was a problem hiding this comment.
| * - `scopeType` — filter by scope type (`SCOPE_TYPES.COURSE` / `course-v1` or `SCOPE_TYPES.LIBRARY` / `lib`) |
| .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')) { |
There was a problem hiding this comment.
| .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) { |
There was a problem hiding this comment.
Thank you, I overlooked that. I'll make the change in PR #269 as getScopeContextType changes, so I make a unique update.
|
🎉 This PR is included in version 1.0.0-alpha.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
LIBRARY_ROLE_KEYSlist with catalog role IDs.scope_type=libinstead of the deprecated library alias.Note
Note on the library-only roles filter. When the user can't view course teams, the team tables send r
oles=<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_subjectchecks the scope's admin-view permission,view_course_teamfor 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
With a user who can view library teams but cannot view course teams:
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