Skip to content

feat(access): roles with permissions and custom roles per namespace - #373

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-a40rui
Oct 15, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-a40rui

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Part 2 of the user manager and RBAC work (part 1 was #286).

Before: a namespace role was one of viewer, editor or owner, and every check compared ranks.

After: a role is a set of permissions (read, edit, import, process, curate, share, publish, remove, members, manage). Viewer, editor and owner are built in and unchanged. Admins make custom roles in Admin › Roles (a permission matrix) or through GET/POST/PATCH/DELETE /api/v1/roles, and give them per namespace like the built-in ones. Changing a role applies at once to everyone holding it, and a role somebody holds can't be deleted.

How: domain/roles.py holds the permission table and the new role table. Principal.perms is resolved next to the ranks, and Access.need/need_in accept a permission name. Routes for import, process, curate, share, publish, remove, members and manage now ask for that permission. Other checks stay rank-based, and a custom role counts as the largest built-in role it fully covers, so it never gets more than its permissions. Someone with the members permission can give only roles whose permissions are within their own, so they can't promote themselves or remove an owner. /auth/me returns permissions per namespace, and the assistant's change_person accepts custom roles.

Motivation and Context

Adeel asked for a user manager and RBAC.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project.
  • I added or updated tests (tests/api/test_roles.py; test_users.py now expects 400 for an unknown role).
  • I updated docs/ (access.md "Roles and permissions", api.md, authentication.md).
  • CHANGELOG.md ## Unreleased.

Done questions

  1. Goal: yes. The user manager was feat(users): email invitations and remove people for good #286; this PR adds roles, permissions and custom roles. It merges on green.
  2. Agents: yes, through the /roles API, /auth/me permissions, and the assistant's change_person with any role.
  3. Zero setup: yes. The role table is defined at startup.
  4. Fewest clicks: yes. One dialog makes a role, and roles show in the existing role pickers.
  5. Configurable: yes, in Admin › Roles. There are no new settings.
  6. Light: yes, nothing heavy added.
  7. Private and secure: yes. P-ROLE was updated and P-ROLE-GRANT added (no granting more than you hold). The YAML and JSON were regenerated and the validator passes.
  8. Cost: n/a, no model calls.
  9. User decides: yes. Built-in roles and all existing access are unchanged, and custom roles exist only when an admin makes them.
  10. Upgrades: n/a. Memberships keep their built-in role names, and the new table starts empty.
  11. Honest: yes, the docs describe only what is built.
  12. Tested and documented: yes. The OpenAPI client was regenerated with make openapi.
  13. Open: n/a.
  14. Reported: in the project thread.

Refine later:

  • Move the remaining rank-based checks (the notebook, resolving comments, collection roles) to permissions, so a custom role gets exactly its permissions there too.
  • Add permission-based collection roles.

🤖 Generated with Claude Code

https://claude.ai/code/session_013CspHV36KRyiRJ9LsFqK53


Generated by Claude Code

Viewer, editor and owner become sets of permissions (read, edit, import,
process, curate, share, publish, remove, members, manage). Admins make
custom roles from them (Admin > Roles, /api/v1/roles) and give them per
namespace like the built-in ones; routes for importing, processing,
curating, sharing, publishing, removing, people and namespace settings
check the permission. Existing access is unchanged. Non-admin members
managers give only roles they hold all of.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CspHV36KRyiRJ9LsFqK53
@adeelahmad adeelahmad self-assigned this Oct 15, 2026
@adeelahmad
adeelahmad merged commit 791d961 into main Oct 15, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-a40rui branch October 15, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants