security rights #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
on a group we can give following rights
then implement this in the server so its enforced
Implementation Spec for Issue #4: Security Rights
Objective
Add a role-based permission system to hero_collab where groups carry security rights that govern what their members can do. Permissions are assigned at the group level and enforced server-side on every mutating RPC call.
Rights Model
A group can be assigned one or more of:
admin— full admin, can do everything across all workspacesworkspace_manage— can create, modify, and delete workspaceschannel_manage— can create, modify, and delete channels in specified workspace(s)workspace_admin— full admin within specified workspace(s)group_manage— can create, modify, and delete groups and their membershipsRights scoped to workspaces (
channel_manage,workspace_admin) store the list of workspace IDs they apply to.Database: New
group_rightsTableNew RPC Methods
group.rights.set— set rights for a group (admin only)group.rights.get— get rights for a groupuser.permissions— resolve effective permissions for a user (union of all group rights, recursively)Enforcement
caller_idparametercaller_idis omitted → no authorization (backward compat)caller_idlacks permission → JSON-RPC error-32003Implementation Steps
GroupRightstruct andgroup_rightstable migrationhandlers/permissions.rswithcheck_permission()andresolve_user_rights()rights_set,rights_gethandlers +user.permissions+ RPC registrationGroupRighttype, rights methods, andcaller_idparam to all mutating callscaller_idparameterAcceptance Criteria
group_rightstable created by migrationgroup.rights.set/group.rights.get/user.permissionswork correctlycaller_idomission = backward compat (no auth check)-32003Implementation Complete
Test Results
All integration tests (
test_rpc_discover,test_server_health), unit tests, and doc-tests pass.Changes Made
New files:
crates/hero_collab_server/src/handlers/permissions.rs— Core permission resolution and checking moduleModified files:
crates/hero_collab_server/src/models.rs— AddedGroupRightstructcrates/hero_collab_server/src/db.rs— Addedgroup_rightstable migrationcrates/hero_collab_server/src/handlers/mod.rs— Registered permissions modulecrates/hero_collab_server/src/handlers/group.rs— Addedrights_set,rights_gethandlers + permission checks on CRUDcrates/hero_collab_server/src/handlers/workspace.rs— Added permission checks to create/update/deletecrates/hero_collab_server/src/handlers/channel.rs— Added permission checks to create/update/archive/deletecrates/hero_collab_server/src/handlers/message.rs— Added permission checks to send/update/delete (authors can edit own messages)crates/hero_collab_server/src/handlers/document.rs— Added permission checks to create/update/delete/sharecrates/hero_collab_server/src/handlers/room.rs— Added permission checks to create/endcrates/hero_collab_server/src/rpc.rs— Registeredgroup.rights.set,group.rights.get,user.permissionscrates/hero_collab_sdk/src/lib.rs— AddedGroupRighttype,group_rights_set,group_rights_get,user_permissionsmethodscrates/hero_collab_server/openrpc.json— AddedGroupRightschema and 3 new method definitionsNotes
caller_idis optional on all mutating RPCs — omitting it bypasses authorization (backward compat)Implementation committed:
f0167b8Browse:
f0167b8