feat(authz): individual capabilities per member (RBAC step 3) #122

Merged
sharang merged 1 commits from feat/extra-capabilities into main 2026-11-11 12:48:54 +00:00
Owner

RBAC plan step 3 (individual capabilities), registry part.

What

  • A member can hold capabilities on top of their one bundle. They live in the Keycloak user attribute extra_capabilities (written like org_roles, read-merge-write of the attributes, cleared when the member leaves). The tenant-context mapper puts it into the token (orca-platform PR, applied to the realm separately).
  • POST /v1/tenants/{id}/members/{uid}/capabilities {"capability"} and DELETE …/capabilities/{cap}.
  • Rules (plan §4): the acting person is an active member who holds registry:members.manage (bundle or extra), never acts on themselves, and grants only what they hold (not_held). in_bundle when the bundle grants it already.
  • Four-eyes: an administration capability (admin in the catalogue) becomes an open request (new table capability_requests, migration 0029). A second such person approves (POST /v1/tenants/{id}/capability-requests/{rid}/approve) or rejects (DELETE …/{rid}); the requester and the member cannot approve. Revoking a capability withdraws its open request; removing a member drops theirs.
  • A role change keeps the extras.
  • authn.Principal parses the extra_capabilities claim. The registry's own checks still go by org_roles (unchanged): an extra such as registry:members.manage works through the portal (service client), not yet with a person's own token against the registry. Moving the registry's handlers onto capabilities is a separate decision.
  • Audit: user.capability_granted|requested|revoked|request_rejected|request_withdrawn.

Behaviour change: none until someone is granted an extra; nobody holds one today.

Tests: handler rules, four-eyes, user tokens, Keycloak adapter (other attributes survive), store on memory and Postgres, OpenAPI.

🤖 Generated with Claude Code

https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf

RBAC plan step 3 (individual capabilities), registry part. **What** - A member can hold capabilities on top of their one bundle. They live in the Keycloak user attribute `extra_capabilities` (written like `org_roles`, read-merge-write of the attributes, cleared when the member leaves). The tenant-context mapper puts it into the token (orca-platform PR, applied to the realm separately). - `POST /v1/tenants/{id}/members/{uid}/capabilities` `{"capability"}` and `DELETE …/capabilities/{cap}`. - Rules (plan §4): the acting person is an active member who holds `registry:members.manage` (bundle or extra), never acts on themselves, and grants only what they hold (`not_held`). `in_bundle` when the bundle grants it already. - Four-eyes: an administration capability (`admin` in the catalogue) becomes an open request (new table `capability_requests`, migration 0029). A second such person approves (`POST /v1/tenants/{id}/capability-requests/{rid}/approve`) or rejects (`DELETE …/{rid}`); the requester and the member cannot approve. Revoking a capability withdraws its open request; removing a member drops theirs. - A role change keeps the extras. - `authn.Principal` parses the `extra_capabilities` claim. The registry's own checks still go by `org_roles` (unchanged): an extra such as `registry:members.manage` works through the portal (service client), not yet with a person's own token against the registry. Moving the registry's handlers onto capabilities is a separate decision. - Audit: `user.capability_granted|requested|revoked|request_rejected|request_withdrawn`. **Behaviour change:** none until someone is granted an extra; nobody holds one today. **Tests:** handler rules, four-eyes, user tokens, Keycloak adapter (other attributes survive), store on memory and Postgres, OpenAPI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
sharang added 1 commit 2026-11-11 12:39:49 +00:00
feat(authz): individual capabilities per member (RBAC step 3)
ci / shared (pull_request) Successful in 26s
ci / test (pull_request) Successful in 6m7s
ci / image (pull_request) Skipped
fe05192182
A member can hold capabilities on top of their bundle. They live in the
Keycloak user attribute extra_capabilities, which the tenant-context
mapper puts into the token; the registry writes it like org_roles and
clears it when the member leaves.

- POST/DELETE /v1/tenants/{id}/members/{uid}/capabilities[/{cap}]
- a person who holds registry:members.manage grants, never on
  themselves, and only what they hold themselves
- an administration capability waits for a second person: open
  requests in capability_requests (0029), approve or reject under
  /v1/tenants/{id}/capability-requests
- a role change keeps the extras; the principal parses the claim, the
  registry's own checks still go by org_roles

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
sharang merged commit c18f0dc945 into main 2026-11-11 12:48:54 +00:00
sharang deleted branch feat/extra-capabilities 2026-11-11 12:48:54 +00:00
Sign in to join this conversation.