Skip to content

Backend: create custom role endpoint #589

Done

Description

@rodmgwgu

Implement the create custom role endpoint defined in the ADR (#469): create a user_defined role for a single resource type with a name, description and an initial permission set, persisted via the custom-roles model (#561) and rendered to Casbin p rows in the same transaction.

Superuser-only. Enforces: single resource type per role; name validation/uniqueness; permission ids valid for the resource type; dependency closure applied (a selected permission pulls in its required dependencies). Backs the create wizard (#571–#573).

Acceptance

  • POST creates a custom role with resource type + permissions; p rows rendered in the same transaction.
  • Superuser-only; non-superuser rejected.
  • Single-resource-type and name-uniqueness validation (400 on violation).
  • Dependency closure enforced server-side (not only in the UI).
  • Audit event recorded (see ADR: Custom roles audit model #587/Implementation: Custom roles audit trail #588); tests for success and each validation path.

Activity

  1. added
    willow
    on Oct 30, 2026
  2. rodmgwgu commented on Nov 5, 2026

    @rodmgwgu
    ContributorAuthor

    Under discussion: the draft Custom Roles API ADR for #469 (ADR 0036, not merged yet) proposes changes that affect this ticket. Nothing is final until the ADR is approved.

    Proposed changes:

    • No server-side dependency closure. The server rejects a permission set that leaves out a dependency with a 400 that lists the missing permissions. The client selects dependencies from the catalog's depends_on lists before saving, so the user sees the full set. This matches the rule ADR 0034 applies to schema roles.
    • A taken name returns 409, not 400. Names are unique among all roles (static and custom), ignoring case.
    • Copying uses this same endpoint with no extra fields. The request always includes display_name, scope_types and permissions. There is no source_role field.
  3. self-assigned this
    on Nov 23, 2026
  4. moved this to In Progress in RBAC AuthZ Boardon Nov 23, 2026
  5. moved this from In Progress to Ready for Review in RBAC AuthZ Boardon Nov 24, 2026
  6. moved this from Ready for Review to In Review in RBAC AuthZ Boardon Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

willow

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions