Skip to content

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

Merged
rodmgwgu merged 1 commit into
mainfrom
docs/custom-role-api
Nov 18, 2026
Merged

rodmgwgu merged 1 commit 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.

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.

This was resolved already in #603

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

@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Nov 16, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Nov 16, 2026
============

Removing a role that has assignments must be confirmed explicitly. The request confirms it with the
``assignments=revoke`` query parameter, which deletes the assignments together with the role.

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.

What other values would assignments accept here? The parameter made sense when it chose between revoke and reassign, but if revoke is the only value left, why don't we use something like revoke=true?

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.

I kept it this way in case we implement the reassign feature in the future, so we don't have to do a breaking change here.

team. Letting them do so later requires a decision on privilege escalation.
* Two roles cannot share a display name, so the assignment wizard and the Team Members view never
show two roles with the same name.
* Clients must compute dependencies before saving. A client that does not gets a 400 that names the

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.

Why is this the client's responsibility and not something the framework does explicitly? I see the server already rejects incomplete sets, and the rejected alternative explains why it doesn't add dependencies silently. But the catalog only returns direct depends_on lists (ADR 0034), so every client has to compute the indirect ones on its own. Could the framework provide that instead?

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.

My original reasoning on ADR 0034 was that the UI would need to do the logic anyway because it needs to automatically select dependencies when a permission is checked, and to warn the user when disabling a permission that another one depends on.

However now that you mention it I think adding the full set of dependencies to the endpoint response is a good idea. I'll add that, thanks!

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.

Done, added an all_depends_on property which lists all dependencies including indirect ones.

@rodmgwgu
rodmgwgu force-pushed the docs/custom-role-api branch from 536bfc8 to 57a98f6 Compare November 17, 2026 22:04

@mariajgrimaldi mariajgrimaldi left a comment

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.

LGTM! Thanks so much for addressing my comments :)

@rodmgwgu
rodmgwgu force-pushed the docs/custom-role-api branch from 57a98f6 to dc5b1d3 Compare November 18, 2026 15:28
@rodmgwgu
rodmgwgu merged commit 25ab080 into main Nov 18, 2026
8 checks passed
@rodmgwgu
rodmgwgu deleted the docs/custom-role-api branch November 18, 2026 15:32
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Nov 18, 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.

ADR: Custom Roles API

5 participants