Skip to content

docs: ADR - API Contract for Custom Roles - #607

Open
rodmgwgu wants to merge 6 commits into
mainfrom
docs/custom-role-api
Open

rodmgwgu wants to merge 6 commits into
mainfrom
docs/custom-role-api

Conversation

@rodmgwgu

@rodmgwgu rodmgwgu commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #469

Problem

The Administrative Console needs to create, list, edit, copy, and remove custom roles, and to move a role's members to another role. ADR 0035 decides how custom roles are stored, but no ADR defines who can manage them or the REST API. The Roles and Permissions table also needs member counts, a last-updated date, search, and sorting, which the role catalog (ADR 0028) does not provide.

Approach

  • Added ADR 0036, which defines:
    • Superuser-only writes for custom roles, with no new permission. Assigning and unassigning custom roles keeps the existing team-management permissions.
    • POST, GET, PATCH, and DELETE on /api/authz/v1/roles/<role>/, plus POST /api/authz/v1/roles/<role>/reassign/.
    • user_count and updated_at on every role, and search, sort_by, and order on the list. Search and sort run in Python so translated static role names match what the user sees.
    • Validation: one resource type per role, at least one permission, and display names unique across all roles ignoring case (409 when taken).
    • No server-side dependency closure. Incomplete permission sets are rejected with a 400 that lists the missing dependencies, following the rule ADR 0034 applies to schema roles.
    • Copying through the create wizard with a required name and no copy endpoint, so role IDs describe the role.
    • Removing a role with assignments requires choosing revoke or reassign, in one transaction.
  • Added an addendum to ADR 0028 for the new role fields, query parameters, and Python-side pagination.

Manual testing instructions

Docs only. Both files pass python -m docutils --halt=warning.

Rollback plan

Revert this PR. Docs only. No code or migration.

Retro compatibility

No behavior change. This PR only records the decision. The implementation will follow in separate PRs.

AI Usage

Kiro assisted with research and ADR authoring, with human guidance on the decisions and validation against the existing ADRs.


Merge checklist:

@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 Nov 5, 2026
@openedx-webhooks

openedx-webhooks commented Nov 5, 2026 •

Copy link
Copy Markdown

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.

sorts them in Python, and then paginates. The list is bounded by the schema roles plus the custom
roles of the instance. User counts are computed with one grouped query, not one query per role.

5. Validation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think for security reasons none of these fields should be editable, not even the permissions, except maybe the description. Editing a role's permissions changes the access of every user who holds it right away, and nothing records who made the change or why. I explained this in more detail in ADR 0035. If roles stay immutable, PATCH would only accept description, and changing permissions would mean creating a new role.

@BryanttV BryanttV 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! Thanks for this! Just one comment.

* - Create
- ``POST /api/authz/v1/roles/``
* - Read one role
- ``GET /api/authz/v1/roles/<role>/``

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.

<role>, refers to role_id, correct? For example: custom_course_manager?

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.

yes!, added clarification

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

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

ADR: Custom Roles API

4 participants