Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 2.09 KB

File metadata and controls

46 lines (33 loc) · 2.09 KB

PR Description

This PR implements the feature described in GitHub issue #465: [Contract] Implement Granular Access Control and Delegation.

Summary

  • Added role-based access control with Role enum (Admin, Keeper, Delegate, Viewer, Auditor)
  • Added fine-grained permission system with Permission enum (TaskCreate, TaskExecute, TaskManage, PortfolioManage, GovernanceVote, GovernancePropose, KeeperRegister, KeeperDelegated, AdminAccess)
  • Implemented role assignment and revocation functionality
  • Implemented permission granting and revocation functionality
  • Implemented permission delegation and revocation functionality
  • Added new DataKey variants for storing role assignments, permission grants, and delegations
  • Added helper functions for managing role-based access control data

Implementation Details

  • Added Role and Permission enums for defining roles and permissions
  • Added RoleAssignment, PermissionGrant, and Delegation structs for storing access control data
  • Added DataKey::RoleAssignments, DataKey::PermissionGrants, DataKey::Delegations, DataKey::RoleAssignmentCounter, DataKey::PermissionGrantCounter, and DataKey::DelegationCounter variants
  • Added helper functions get_role_assignment, set_role_assignment, get_permission_grant, set_permission_grant, get_delegation, set_delegation, and their counter variants
  • Added contract functions assign_role, revoke_role, grant_permission, revoke_permission, delegate_permission, and revoke_delegation
  • All functions include proper security guards and authorization checks
  • Added appropriate events for monitoring access control changes

Testing

  • Added comprehensive unit tests for all new access control functionality
  • Tests verify role assignment and revocation
  • Tests verify permission granting and revocation
  • Tests verify permission delegation and revocation
  • Tests verify proper authorization checks

Related Issues

  • Closes #465

Checklist

  • Code follows project conventions
  • Tests pass
  • Documentation updated
  • Security review completed

Reviewers

@serverlessdomain-hash