Repository navigation
Description
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;400for roles not inresource_roles,409for the last owner. Owners may only grant roles to groups they are members of, admins to any group (403otherwise).deleteUserRole,deleteGroupRole: revoke the roles of a subject;404if it has none,409for 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
uniqueg commentedon Oct 22, 2026
Done in #382.