This PR implements the feature described in GitHub issue #465: [Contract] Implement Granular Access Control and Delegation.
- 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
- Added
RoleandPermissionenums for defining roles and permissions - Added
RoleAssignment,PermissionGrant, andDelegationstructs for storing access control data - Added
DataKey::RoleAssignments,DataKey::PermissionGrants,DataKey::Delegations,DataKey::RoleAssignmentCounter,DataKey::PermissionGrantCounter, andDataKey::DelegationCountervariants - 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, andrevoke_delegation - All functions include proper security guards and authorization checks
- Added appropriate events for monitoring access control changes
- 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
- Closes #465
- Code follows project conventions
- Tests pass
- Documentation updated
- Security review completed
@serverlessdomain-hash