Skip to content

feat(sharing): per-resource-type share roles, incl. a role that manages shares (#707) - #719

Merged
antosubash merged 4 commits into
mainfrom
feat/b32-sharing-roles
Oct 30, 2026
Merged

antosubash merged 4 commits into
mainfrom
feat/b32-sharing-roles

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Resource types can now declare their own sharing roles, including a role that lets a non-owner manage shares.

Closes #707

What changed

  • ResourceType.share_roles (keyword-only): a mapping of role id → the actions it implies, e.g. {"viewer": ("view",), "contributor": ("view", "edit"), "manager": ("view", "edit", "share")}. None keeps today's view/edit roles.
    • Registration checks each role id (lowercase, at most 32 characters, the width of the stored column) and that each role includes view, since visibility decides 404 versus 403.
  • sharing resolves roles per type: roles_granting(action, roles=…), share_exists_for(type, id_col, roles=…) and resolve_roles(). grant() validates the role against the type's mapping.
    • A module passes the same mapping constant to ResourceType and to share_exists_for; the docs and a wiring test cover it.
    • If the two ever drift, access fails closed.
  • Delegated share management. A role that implies ACTION_SHARE lets its holder list, grant and revoke shares on that resource, for any role the type declares (no ranking, per the approved design). The API's sharing.share permission gate still applies.
  • Deprecated: ResourceType.shareable_actions (remove_in="0.1.0", listed in test_deprecation_expiry). view/edit subsets keep working through the shim.
    • Behaviour change: the field now defaults to None instead of ("view", "edit"); read share_roles.
    • Legacy values that aren't valid role ids now fail at registration. They never granted anything before.
  • Removing a role from a mapping revokes the access of shares stored with it; the docs now say so.
  • No migration: ResourceShare.role is already a string.

Verification

  • make lint ✓ · make test-js ✓ · make test-py ✓ (6591 passed, 41 skipped)
  • test_sharing_custom_roles.py: default compatibility; two types with different roles; custom-action SQL access; manager grant, list and revoke; viewer refused; unknown role; expiry; cross-tenant; role-id validation (including a trailing newline that match + $ let through, which review caught); deprecation shim.
  • Code review: two passes. Fixes: role-id validation, the fullmatch bug, changelog placement, docs. Rejected findings are recorded with reasons.
  • No browser QA: the only UI change is that the share table shows custom role ids; a vitest covers it.

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1d6aa92
Status: ✅  Deploy successful!
Preview URL: https://a020930f.simple-module-python.pages.dev
Branch Preview URL: https://feat-b32-sharing-roles.simple-module-python.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-30T22:48:42.186237Z 1d6aa92 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit 5bea876 into main Oct 30, 2026
16 checks passed
@antosubash
antosubash deleted the feat/b32-sharing-roles branch October 30, 2026 22:53
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.

sharing: per-resource-type roles (role → implied actions), incl. a role that may manage shares

1 participant