Skip to content

Validate permission dependencies in the custom role create and update endpoints #674

In review

Description

@rodmgwgu

Follow-up from #589 and #590. Both list a server-side permission dependency check in their acceptance criteria, but #647 (create) and #649 (update) shipped without it because dependencies were not stored in the schema yet. They are now: #648 added depends_on and #657 stores it in AuthzPermissionDependency and renders it as g2 rows.

Validate permission dependencies when a custom role is created or edited, as ADR 0036 section 7 requires:

  • POST /api/authz/v1/roles/ and PATCH /api/authz/v1/roles/<role_id>/ reject a permission set that leaves out a direct or indirect dependency of another permission in the set. The response is 400 and lists the missing dependencies.
  • This covers both adding a permission without its dependencies and removing a dependency that another permission still needs.
  • The server does not add dependencies.
  • The check goes in the custom roles API (create_custom_role and update_custom_role), so both endpoints get it.

Acceptance

  • Both endpoints return 400 listing the missing dependencies, including indirect ones.
  • A rejected request changes nothing.
  • Tests cover a complete set, a missing direct dependency, a missing indirect dependency, and an edit that removes a needed dependency.
  • Remove the "Permission dependencies are not checked yet" notes from the endpoint docstrings and CHANGELOG.

To decide

  • Hidden dependencies: since feat: add the endpoint to edit custom roles #649, an edit keeps hidden permissions the role already grants, and clients cannot send hidden IDs. Those kept grants should count as present. No visible built-in permission depends on a hidden one today, so this only affects schemas that add such a dependency later.

The catalog's all_depends_on field (also ADR 0036 section 7) belongs with #574.

Metadata

Metadata

Assignees

Labels

willow

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions