Skip to content

feat(access-control): add resource role controllers #355

Closed

Description

@uniqueg

Why?

Part 2 of #341 (closes #341 together with part 1): ready-made controllers for managing roles on resources, so that apps like proTES expose cloud-registry's permission endpoints under their own paths without writing controllers. Apps with special needs (e.g., cloud-registry's display names) keep their own controllers on top of the helpers.

How?

New module foca.security.access_control.ownership_server with controllers that apps route to from their API specifications (x-openapi-router-controller), for example at /tasks/{id}/permissions, /tasks/{id}/permissions/users/{userId} and /tasks/{id}/permissions/groups/{group}:

  • getResourceRoles: lists the roles granted on the resource (subject_type, subject, role).
  • putUserRole, putGroupRole: grant the role in the request body ({"role": ...}), replacing other roles; 400 for roles not in resource_roles, 409 for the last owner. Owners may only grant roles to groups they are members of, admins to any group (403 otherwise).
  • deleteUserRole, deleteGroupRole: revoke the roles of a subject; 404 if it has none, 409 for the last owner.

The resource is taken from the route: the path up to the last path parameter before the subject's (e.g., /tasks/{id}). Resources without owners are not found (404); a role granted on a resource whose owners vanished meanwhile (deleted concurrently) is revoked again. Who may call the endpoints is decided by the app's policies (e.g., p, owner, /tasks/:id/permissions/*, (GET)|(PUT)|(DELETE)), as for any other operation; traffic is logged as for FOCA's permissions API (log_traffic).

Acceptance criteria

  • Tests cover the controllers through a test API, including path parameters with any names, groups with slashes, the last-owner rule and the group membership check.
  • Documented, with a specification snippet and the policies apps need.

Activity

  1. added
    priority: medium
    status: blocked
    type: auth
    type: feature
    workload: hours
    on Oct 21, 2026
  2. added
    status: in progress
    and removed
    status: blocked
    on Oct 22, 2026
  3. uniqueg commented on Oct 22, 2026

    @uniqueg
    MemberAuthor

    Done in #382.

  4. removed
    status: in progress
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype: authtype: featureworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions