Skip to content

feat: Implemented team member assignments endpoint#248

Merged
rodmgwgu merged 11 commits intoopenedx:mainfrom
WGU-Open-edX:rod/user-assignments-endpoint
Apr 15, 2026
Merged

feat: Implemented team member assignments endpoint#248
rodmgwgu merged 11 commits intoopenedx:mainfrom
WGU-Open-edX:rod/user-assignments-endpoint

Conversation

@rodmgwgu
Copy link
Copy Markdown
Contributor

@rodmgwgu rodmgwgu commented Apr 2, 2026

Description

Closes: #230

Implement the /api/authz/v1/users/<username>/assignments endpoint to get a list of role assignations for a user, to be used in the admin console.

Special case: superadmin users (Django staff or superuser) automatically have access to everything, so if we query for a superadmin user, we'll get an extra entry indicating the superadmin status.

Deadline: Verawood

How to test

Using a local dev tutor installation, call the following endpoint with required credentials:

http://local.openedx.io:8000/api/authz/v1/users/<username>/assignments

The user you use to test this should have permission to at least view one course or library.

You should see a response similar to this:

{
    "count": 6,
    "next": null,
    "previous": null,
    "results": [
        {
            "is_superadmin": false,
            "role": "course_admin",
            "org": "WGU",
            "scope": "course-v1:WGU+TC101+2026_01",
            "permission_count": 29
        },
        {
            "is_superadmin": false,
            "role": "course_staff",
            "org": "WGU",
            "scope": "course-v1:WGU+TC101+2026_01",
            "permission_count": 27
        },
        {
            "is_superadmin": true,
            "role": "django.superuser",
            "org": "*",
            "scope": "*",
            "permission_count": null
        },
        {
            "is_superadmin": false,
            "role": "library_admin",
            "org": "WGU",
            "scope": "lib:WGU:CSPROB",
            "permission_count": 11
        }
    ]
}

You can also test with params, for example:

http://local.openedx.io:8000/api/authz/v1/users/contributor/assignments?orgs=OpenedX,WGU&roles=library_contributor&sort_by=org&order=desc

Merge checklist:

Merge checklist:
Check off if complete or not applicable:

  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

@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 Apr 2, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 2, 2026

Thanks for the pull request, @rodmgwgu!

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

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.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 2, 2026
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Apr 6, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Apr 6, 2026
@rodmgwgu rodmgwgu force-pushed the rod/user-assignments-endpoint branch 4 times, most recently from ef2d318 to 4b2b47c Compare April 10, 2026 22:15
@rodmgwgu rodmgwgu marked this pull request as ready for review April 10, 2026 22:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements a new REST endpoint to list role assignments for a specific user (including a special-case “superadmin” entry) for use in the Admin Console.

Changes:

  • Added /api/authz/v1/users/<username>/assignments API view, serializers, ordering filter, and sorting utility.
  • Introduced SuperAdminAssignmentData and API helpers to surface Django staff/superuser status as an assignment entry.
  • Added unit tests for the new endpoint and sort_assignments, and bumped version/changelog.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
openedx_authz/rest_api/v1/views.py Adds TeamMemberAssignmentsAPIView that aggregates superadmin + visible role assignments, then sorts/paginates.
openedx_authz/rest_api/v1/urls.py Registers the new user assignments route.
openedx_authz/rest_api/v1/serializers.py Adds query-param serializer + response serializer for assignment entries.
openedx_authz/rest_api/v1/filters.py Adds ordering backend for assignments.
openedx_authz/rest_api/utils.py Adds sort_assignments helper.
openedx_authz/rest_api/data.py Adds AssignmentSortField enum.
openedx_authz/api/users.py Adds APIs to fetch visible assignments for a specific user + superadmin assignment generation.
openedx_authz/api/data.py Adds SuperAdminAssignmentData data class.
openedx_authz/tests/rest_api/test_views.py Adds endpoint-level test suite for user assignments endpoint.
openedx_authz/tests/rest_api/test_utils.py Adds unit tests for sort_assignments invalid parameter handling.
openedx_authz/init.py Version bump to 1.6.0.
CHANGELOG.rst Changelog entry for the new endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openedx_authz/rest_api/utils.py Outdated
Comment thread openedx_authz/api/users.py Outdated
Comment thread openedx_authz/api/users.py Outdated
Comment thread openedx_authz/rest_api/v1/urls.py
Comment thread openedx_authz/tests/rest_api/test_views.py
Comment thread openedx_authz/tests/rest_api/test_views.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openedx_authz/api/users.py Outdated
Comment thread openedx_authz/api/users.py Outdated
Comment thread openedx_authz/rest_api/v1/serializers.py Outdated
Comment thread CHANGELOG.rst Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openedx_authz/tests/rest_api/test_views.py
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openedx_authz/rest_api/utils.py Outdated
Comment thread openedx_authz/rest_api/v1/views.py
Comment thread openedx_authz/rest_api/v1/views.py Outdated
Comment thread openedx_authz/rest_api/v1/views.py
Comment thread openedx_authz/api/data.py Outdated
Comment thread openedx_authz/api/users.py
Comment thread openedx_authz/rest_api/v1/serializers.py Outdated
Comment thread openedx_authz/api/users.py Outdated
Comment thread openedx_authz/tests/rest_api/test_utils.py
Comment thread openedx_authz/tests/rest_api/test_utils.py
Comment thread openedx_authz/api/users.py
@rodmgwgu rodmgwgu force-pushed the rod/user-assignments-endpoint branch from cf18189 to f13a62a Compare April 14, 2026 18:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openedx_authz/api/users.py
Comment thread openedx_authz/rest_api/v1/views.py
# Retrieve superadmin assignments (django staff or superuser users), as they always have access to everything
user_role_assignments += get_superadmin_assignments(user_external_keys=[username])

user_role_assignments += get_visible_user_role_assignments_filtered_by_current_user(
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.

Since get_superadmin_assignments filters by is_active=True, should we apply the same filter for non-staff/non-superusers?

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.

Good catch, fixed!, I also added a test for this.

Copy link
Copy Markdown
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

LGTM after addressing Daniel's comment. Thanks a lot!

@rodmgwgu rodmgwgu requested a review from dwong2708 April 15, 2026 18:37
Copy link
Copy Markdown
Contributor

@dwong2708 dwong2708 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@rodmgwgu rodmgwgu merged commit a18df56 into openedx:main Apr 15, 2026
8 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Apr 15, 2026
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). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Task - RBAC AuthZ - Implement user assignments endpoint for Admin Console

6 participants