Feat/role based access control#346
Merged
Jagadeeshftw merged 5 commits intoJagadeeshftw:masterfrom Feb 1, 2026
Merged
Conversation
|
@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. |
Owner
|
@Samaro1 resolve the conflicts |
d4d60ab to
acb66b9
Compare
Contributor
Author
|
Good morning @Jagadeeshftw I have resolved the conflicts |
Owner
|
@Samaro1 few more conflicts |
acb66b9 to
a9b69f0
Compare
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
7c36bda to
cc2d03c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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