Skip to content

feat: implement admin role management and access control system#60

Merged
Naomi-Gift merged 4 commits intoHubDApp:mainfrom
CollinsC1O:admin
Feb 26, 2026
Merged

feat: implement admin role management and access control system#60
Naomi-Gift merged 4 commits intoHubDApp:mainfrom
CollinsC1O:admin

Conversation

@CollinsC1O
Copy link
Contributor

Admin Role Management and Access Control

Closes #23

Summary

Implemented a comprehensive admin role management system with secure access control for privileged contract operations including verification approvals, treasury access, and fee management.

Changes

New Module: admin_manager.rs

  • Admin initialization, addition, and removal functionality
  • Admin status checking and listing
  • Protection against removing the last admin
  • Event emission for admin changes

Updated Modules

  • storage_keys.rs: Added Admin(Address) and AdminList storage keys
  • errors.rs: Added CannotRemoveLastAdmin and AdminNotFound error types
  • events.rs: Added publish_admin_added_event and publish_admin_removed_event
  • lib.rs: Exposed admin management functions in contract interface
  • verification_registry.rs: Enforced admin-only access for approve/reject operations
  • fee_manager.rs: Enforced admin-only access for fee configuration

Access Control

All privileged operations now require admin authorization:

  • ✅ Verification approval/rejection
  • ✅ Fee configuration
  • ✅ Admin management (add/remove)

Safety Features

  • Cannot remove the last admin (prevents lockout)
  • All admin operations emit events for transparency
  • Comprehensive authorization checks with descriptive error messages

Contract compiles successfully

Screenshot 2026-02-26 at 00 33 16

Testing

  • 13 unit tests covering all admin functionality
  • Integration tests for admin-protected operations
  • Tests for unauthorized access attempts
  • All tests passing ✅
Screenshot 2026-02-26 at 00 27 37

New Public Functions

pub fn initialize(env: Env, admin: Address)
pub fn add_admin(env: Env, caller: Address, new_admin: Address)
pub fn remove_admin(env: Env, caller: Address, admin_to_remove: Address)
pub fn is_admin(env: Env, address: Address) -> bool
pub fn get_admin_list(env: Env) -> Vec<Address>
pub fn get_admin_count(env: Env) -> u32

@Naomi-Gift
Copy link
Contributor

@CollinsC1O please resolve conflicts
pull and push again

@Naomi-Gift Naomi-Gift merged commit 49320b5 into HubDApp:main Feb 26, 2026
0 of 3 checks passed
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.

Admin Role Management and Access Control

2 participants