Skip to content

Implement Role-Based Access Control (RBAC) for Asset Management#361

Merged
truthixify merged 3 commits intoDistinctCodes:mainfrom
codebestia:feat/access-control
Oct 4, 2025
Merged

Implement Role-Based Access Control (RBAC) for Asset Management#361
truthixify merged 3 commits intoDistinctCodes:mainfrom
codebestia:feat/access-control

Conversation

@codebestia
Copy link
Copy Markdown
Contributor

Summary

This PR implements comprehensive role-based access control across the AssetUp smart contracts, ensuring only authorized users can perform restricted actions like branch creation, asset tokenization, and audit logging.

Changes Made

  • Enhanced existing admin storage and initialization in lib.rs
  • Restricted create_branch to global admin only using require_auth()
  • Restricted tokenize_asset to global admin only using require_auth()
  • Created new audit_log.rs module with two access-controlled functions:
    • log_audit_action_as_owner: Only asset owners can log actions
    • log_audit_action_as_admin: Only global admin can log actions

🧪 Comprehensive Testing

  • Created comprehensive tests verifying RBAC enforcement
  • Verify authorized users can perform actions
  • Verify unauthorized access is properly blocked
  • Verify multiple audit logs can be created for the same asset

Acceptance Criteria Met

  • Only global admin can create branches and tokenize assets
  • Only asset owners or global admin can log audit actions
  • Tests confirm access control enforcement

Related Issue

Closes #252

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 4, 2025

@codebestia is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@codebestia
Copy link
Copy Markdown
Contributor Author

GM @truthixify
Please review

@truthixify
Copy link
Copy Markdown
Collaborator

Thank you @codebestia

@truthixify truthixify merged commit 54522d7 into DistinctCodes:main Oct 4, 2025
4 of 5 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.

[CONTRACT] Add Access Control for Admin and Branch Admins

2 participants