Skip to content

Feat/role based access control#346

Merged
Jagadeeshftw merged 5 commits intoJagadeeshftw:masterfrom
Samaro1:feat/role-based-access-control
Feb 1, 2026
Merged

Feat/role based access control#346
Jagadeeshftw merged 5 commits intoJagadeeshftw:masterfrom
Samaro1:feat/role-based-access-control

Conversation

@Samaro1
Copy link
Contributor

@Samaro1 Samaro1 commented Jan 31, 2026

This PR introduces a flexible role-based access control (RBAC) system to both bounty_escrow and program-escrow contracts, expanding control beyond a single administrator. The system supports four hierarchical roles: Admin, Operator, Pauser, Viewer, enabling granular and auditable permissions while remaining backward compatible with existing admin-driven flows.

The RBAC matrix and core logic live in:
contracts/bounty_escrow/contracts/escrow/src/rbac.rs
contracts/program-escrow/src/rbac.rs

Key Features
RBAC Implementation
Hierarchical roles: Admin → Operator → Pauser → Viewer
Public APIs:
grant_role()
revoke_role()
has_role()

Authorization helpers:
require_role()
require_admin()
Updated pause() / unpause() to require caller address and enforce RBAC
Events emitted for auditability:
role_add
role_rm
pause
unpause
Backward Compatibility
Existing admin is automatically treated as Admin on initialization
Critical admin-only flows continue to work under the Admin role
No breaking changes to general contract behavior (except explicit caller argument for pause/unpause)
Contract-Specific Enhancements
bounty_escrow
Full RBAC role management added
Fixed pause state persistence bug (moved to persistent storage)

All tests passing (63/63)
program-escrow
Integrated RBAC checks into pause/unpause and operational paths
Removed duplicate RBAC implementations, keeping a single canonical module
Added anti-abuse rate limiting, monitoring, and emergency withdrawal when paused
Replaced deprecated String::from_slice() with String::from_str()

All RBAC/pause tests passing (21/21)
Pre-existing token minting test failures remain unchanged

Testing
Added dedicated RBAC and authorization tests for both contracts
Verified role grant, revoke, and enforcement paths
Fixed previously failing schedule/pause related tests in program-escrow
Overall RBAC functionality fully covered by passing tests

Modified
bounty_escrow/contracts/escrow/src/lib.rs – integrated RBAC, updated pause/unpause, added authorization checks
bounty_escrow/contracts/escrow/src/events.rs – adjusted event symbols to Soroban limits
program-escrow/src/lib.rs – integrated RBAC checks, removed duplicate RBAC code, updated pause/unpause
program-escrow/src/pause_tests.rs – updated tests to use caller-based pause/unpause

Closes #303

@vercel
Copy link

vercel bot commented Jan 31, 2026

@Samaro1 is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Jagadeeshftw Jagadeeshftw self-requested a review January 31, 2026 09:22
@Jagadeeshftw
Copy link
Owner

@Samaro1 resolve the conflicts

@Samaro1 Samaro1 force-pushed the feat/role-based-access-control branch from d4d60ab to acb66b9 Compare January 31, 2026 09:28
@Samaro1
Copy link
Contributor Author

Samaro1 commented Jan 31, 2026

Good morning @Jagadeeshftw I have resolved the conflicts

@Jagadeeshftw
Copy link
Owner

@Samaro1 few more conflicts

@Samaro1 Samaro1 force-pushed the feat/role-based-access-control branch from acb66b9 to a9b69f0 Compare January 31, 2026 10:34
@Jagadeeshftw
Copy link
Owner

@Samaro1 Can you please resolve it for one more time

- Added RBAC module with hierarchical roles: Admin, Operator, Pauser, Viewer
- Integrated role checks into pause/unpause and initialization functions
- Updated pause_contract() and unpause_contract() to require caller parameter and enforce RBAC
- Pauser role can pause; only Admin can unpause (backward compatible)
- Added grant_role(), revoke_role(), and get_role() management endpoints
- Initialized admin with Admin role on contract initialization for backward compatibility
- Emits role change events for auditability
- Role enum is contracttype for Soroban serialization

Affected files:
- contracts/program-escrow/src/rbac.rs (new RBAC module)
- contracts/program-escrow/src/lib.rs (integrated RBAC checks, updated pause functions)

The bounty_escrow trait impl conflicts need resolution in separate commit.

No breaking changes to contract behavior except:
- pause() and unpause() now require caller parameter
- All role management and enforcement is new functionality
@Samaro1 Samaro1 force-pushed the feat/role-based-access-control branch from 7c36bda to cc2d03c Compare February 1, 2026 19:25
@Jagadeeshftw Jagadeeshftw merged commit 319e461 into Jagadeeshftw:master Feb 1, 2026
0 of 2 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.

Implement Role-Based Access Control (RBAC)

2 participants

Comments