Skip to content

feat: adding bulk user validation endpoint for admin console#245

Merged
rodmgwgu merged 3 commits intoopenedx:mainfrom
WGU-Open-edX:jd/validate-users
Apr 14, 2026
Merged

feat: adding bulk user validation endpoint for admin console#245
rodmgwgu merged 3 commits intoopenedx:mainfrom
WGU-Open-edX:jd/validate-users

Conversation

@jacobo-dominguez-wgu
Copy link
Copy Markdown
Contributor

@jacobo-dominguez-wgu jacobo-dominguez-wgu commented Apr 1, 2026

Description

Implements a new api/authz/v1/users/validate/ endpoint for bulk user validation to support admin console operations during role assignments.
Accepts a JSON payload with a users array containing usernames and/or email addresses, validates the list of input data using serializer and checks for required field, proper format, deduplication, and finally processes each identifier individually to check existence.
Required permissions: manage_library_team OR manage_course_team in any scope.
Superuser/staff bypass.

It resolves #232

Deadline: Verawood.

Testing instructions

Make sure to have a local tutor dev installation.
Only users with team manage permissions are allowed to use this endpoint.

POST http://local.openedx.io:8000/api/authz/v1/users/validate/

{
  "users": [
    "user.invalide@example.com", "duplicated_user", "duplicated_user", "any_valid_user"
  ]
}

Expected response:

{
  "valid_users": [
    "any_valid_user",
  ],
  "invalid_users": [
    "user.invalide@example.com",
    "duplicated_user",
  ],
  "summary": {
    "total": 3,
    "valid_count": 1,
    "invalid_count": 2
  }
}

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
Copy link
Copy Markdown

Thanks for the pull request, @jacobo-dominguez-wgu!

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.

@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 1, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 1, 2026
Comment thread openedx_authz/rest_api/v1/permissions.py Outdated
Comment thread openedx_authz/rest_api/v1/permissions.py Outdated
@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 Ready for Review in Contributions Apr 6, 2026
@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Apr 6, 2026
Comment thread openedx_authz/rest_api/v1/fields.py Outdated
Comment thread openedx_authz/rest_api/v1/permissions.py Outdated
@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the jd/validate-users branch 3 times, most recently from 34d9a6c to 0cfab17 Compare April 10, 2026 16:16
Comment thread openedx_authz/rest_api/v1/serializers.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

Adds a new bulk user validation endpoint to support admin console role-assignment flows by validating a list of usernames/emails and returning valid/invalid identifiers plus summary counts.

Changes:

  • Introduces POST /api/authz/v1/users/validate/ with Any-scope manage-permissions enforcement and structured response.
  • Adds request/response serializers (including a summary sub-serializer) and routes the endpoint in v1 URLs.
  • Adds a comprehensive REST API test suite for the new endpoint and bumps version/changelog.

Reviewed changes

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

Show a summary per file
File Description
openedx_authz/rest_api/v1/views.py Adds UserValidationAPIView endpoint implementation, permissions, and API doc schema.
openedx_authz/rest_api/v1/urls.py Registers the new users/validate/ route.
openedx_authz/rest_api/v1/serializers.py Adds request/response serializers for bulk validation.
openedx_authz/rest_api/v1/fields.py Adds a serializer for response summary statistics.
openedx_authz/tests/rest_api/test_views.py Adds test coverage for request validation, permissions, deduplication, and responses.
openedx_authz/init.py Bumps package version to 1.6.0.
CHANGELOG.rst Adds 1.6.0 release notes 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/v1/views.py Outdated
Comment thread openedx_authz/tests/rest_api/test_views.py Outdated
Comment thread openedx_authz/rest_api/v1/serializers.py
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 7 out of 7 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/rest_api/v1/views.py
Comment thread openedx_authz/rest_api/v1/views.py Outdated
Comment thread openedx_authz/rest_api/v1/views.py Outdated
Comment thread openedx_authz/rest_api/v1/fields.py Outdated
Copy link
Copy Markdown
Contributor

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Functionality looks good, just one nit change.

Also, please run make format before pushing changes, so we get uniform code style.

Thanks!

Comment thread openedx_authz/rest_api/v1/views.py
Comment thread openedx_authz/api/users.py Outdated
except User.DoesNotExist:
invalid_users.append(user_identifier)
except Exception as e:
logger.error(f"Unexpected error validating user {user_identifier}: {e}")
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.

If we are already logging this in the controller, I think we can remove this from here and the logger instance.

Copy link
Copy Markdown
Contributor

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

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!

@mariajgrimaldi
Copy link
Copy Markdown
Member

@jacobo-dominguez-wgu: can we rebase so we can merge? Thanks!

Comment thread CHANGELOG.rst
@rodmgwgu rodmgwgu merged commit 1ff2152 into openedx:main Apr 14, 2026
8 checks passed
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Apr 14, 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 endpoint to validate users on role assignations

6 participants