Repository navigation
Closed
Labels
willowReleased in Willow
Description
The openedx-authz REST API will be extended to support the Custom Roles feature. This ADR specifies the API contract: the endpoints, their request/response shapes, authorization, validation rules, and how they relate to the existing roles/catalog/assignment APIs. It is the single source of truth for the backend contract; the per-feature backend issues listed below implement against it.
Use cases to cover
- CRUD for custom roles
- Create a
user_definedrole for a single resource type with name, description and an initial permission set. - Read — custom roles appear in the existing catalog (
GET /api/authz/v1/roles/, ADR 0028) distinguished bydefinition_kind(static/user_defined). - Update — rename / edit description (metadata) and add/remove permissions.
- Delete — remove a custom role, with the two deletion paths below.
- Create a
- Add or remove permissions to a custom role, applying dependency closure (selecting a permission pulls in its required dependencies; see the permission-dependencies epic EPIC: Permission dependencies mapping #559).
- Duplicate role (from a standard or custom source): copy the source's resource type and permission set into a new
user_definedrole; the resource type cannot be changed; only the definition is copied, not member assignments. - Reassign role members to another role (used by delete-with-reassign and as a standalone operation).
- Delete paths:
- Delete + revoke ("Delete anyway"): delete the role and unassign all its members.
- Reassign + delete ("Reassign & Delete"): reassign all members to a replacement role, then delete.
- Impact reporting: expose how many users and scopes a role affects, so the edit banner ("assigned to N members") and the delete/reassign modals can show counts before acting. Confirm whether the existing user/assignment endpoints (ADR 0024,
assignment_count+ member listing) already return this in one call or whether a dedicated endpoint is needed.
Decisions to record
- Authorization — superuser-only for writes. Create, update (metadata + permissions), duplicate and delete of custom roles are restricted to platform superusers. (This removes privilege-escalation concerns, since a superuser already holds every permission.) Assign and revoke keep the existing per-resource-type assignment permissions. Reading the catalog is unchanged (ADR 0028). No new gating permission is introduced for the write path.
- Single resource type per custom role. A custom role applies to exactly one resource type (Courses or Libraries); the create/duplicate endpoints enforce this. Multi-resource-type roles are out of scope for this phase (the old Support more than one scope type per role #466 was dropped).
- Terminology. The user-facing term for Courses / Libraries is "resource type"; backend keys remain
scope_typesand thecourse-v1/libnamespaces (ADR 0028) — the decision governs UI/prose, not the wire format. - Name & description. Name is validated for uniqueness; description is free text stored as entered by the admin (not localized — custom-role names/descriptions are explicitly out of i18n scope).
- Casbin lifecycle. Create/update/delete render or remove the role's Casbin
prows in the same transaction as the definition changes, following the pattern ADR 0025 uses for static definitions. - Audit. Lifecycle events are audited — the audit model is specified in its own ADR (see the Custom roles audit trail epic).
Realizing issues (implemented against this contract)
- Create: Backend: create custom role endpoint #589 (backend) ← wizard Frontend: Create Custom Role button + wizard page 1 (Name & Resource) #571–Frontend: Custom role creation call + status toast #573 (frontend)
- Update (metadata + permissions): Backend: update custom role (metadata + permissions) endpoints #590 (backend) ← rename Frontend: Edit a custom role description (inline pencil) #578, editable Permissions tab Frontend: Role detail Permissions tab (custom roles, editable) #577 (frontend)
- Read / catalog controls: Backend: roles catalog search, filter, sort, pagination #569 (search/filter/sort/pagination) ← table Frontend: Roles and Permissions table view #568, detail Frontend: Role detail view Members tab #575–Frontend: Role detail Permissions tab (standard roles, read-only comparison matrix) #576
- Permission dependencies in the response: Backend: permission dependencies in the catalog response #574 (blocked on Implementation: Permission dependencies mapping via Yaml extensibility #560)
- Duplicate: Backend: duplicate role #580 (backend) ← Frontend: Duplicate role (row + detail kebab) opens create wizard in clone mode #583 (frontend)
- Delete (both paths): Backend: read and remove custom role endpoints #581 (backend) ← Frontend: Delete custom role (row + detail kebab) #584, Frontend: Delete confirmation + reassign-before-delete modals #585 (frontend)
- Reassign members: Backend: reassign role members to another role #582 (backend) ← used by Frontend: Delete confirmation + reassign-before-delete modals #585; revoke Frontend: Revoke role assignment modal + toast #586 reuses existing unassign
- General implementation umbrella: Implementation: Custom Roles API #470
Create an ADR specifying the contract above.
Metadata
Metadata
Assignees
Labels
willowReleased in Willow
Type
Projects
- StatusShow more project fieldsDone
Activity