You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -25,15 +25,14 @@ Manages role-based access control within a diamond.
25
25
</DocSubtitle>
26
26
27
27
<Callouttype="info"title="Key Features">
28
-
- Permission management via roles and accounts.
29
-
- Role hierarchy support with administrative roles.
30
-
- Batch operations for granting and revoking roles.
31
-
- Reverts with specific errors for unauthorized actions.
28
+
- Hierarchical role administration: roles can have their own admin roles.
29
+
- Batch operations for granting and revoking multiple roles efficiently.
30
+
- Explicit error messages for unauthorized access attempts.
32
31
</Callout>
33
32
34
33
## Overview
35
34
36
-
The AccessControlFacet provides a robust role-based access control (RBAC) system for Compose diamonds. It allows granular permission management, enabling developers to define roles and assign them to accounts. This facet is crucial for orchestrating secure interactions by enforcing role requirements on sensitive functions.
35
+
The AccessControlFacet provides a robust role-based access control (RBAC) system for Compose diamonds. It enables granular permission management by defining roles, assigning them to accounts, and enforcing role requirements on function calls. This facet is crucial for securing administrative functions and controlling access to sensitive operations.
- Initialize roles and grant initial permissions during diamond deployment.
521
-
-Use `grantRoleBatch` and `revokeRoleBatch` for efficient multi-account role management.
522
-
-Design roles with clear administrative hierarchies using `setRoleAdmin`.
516
+
- Initialize roles and their admins during diamond deployment using `DiamondInit`.
517
+
-Grant roles to specific addresses or multisigs, avoiding broad grants to `address(0)`.
518
+
-Use `requireRole` judiciously within other facets to protect sensitive functions.
523
519
</Callout>
524
520
525
521
## Security Considerations
526
522
527
523
<Callouttype="warning"title="Security">
528
-
Ensure that the administrative roles are protected to prevent unauthorized role modifications. Sensitive functions should use `requireRole`to enforce access control. Be mindful of gas costs when performing batch operations on very large sets of accounts.
524
+
Ensure that the caller of `setRoleAdmin`, `grantRole`, `revokeRole`, `grantRoleBatch`, and `revokeRoleBatch` is authorized by the role's admin. Be cautious when setting role admins to prevent privilege escalation. Reentrancy is not a direct concern for this facet's core logic, but ensure calling facets properly validate inputs before calling `requireRole`.
@@ -26,8 +26,9 @@ Manage roles and permissions within a diamond.
26
26
27
27
<Callouttype="info"title="Key Features">
28
28
- Role-based access control for granular permission management.
29
-
- Standardized interface for granting, revoking, and checking roles.
30
-
- Support for defining and assigning admin roles to manage other roles.
29
+
- Functions to grant, revoke, and check for role ownership (`grantRole`, `revokeRole`, `hasRole`).
30
+
- Support for setting and changing the administrative role for any given role (`setRoleAdmin`).
31
+
- Built-in reversion with `AccessControlUnauthorizedAccount` for unauthorized access attempts.
31
32
</Callout>
32
33
33
34
<Callouttype="info"title="Module Usage">
@@ -36,7 +37,7 @@ This module provides internal functions for use in your custom facets. Import it
36
37
37
38
## Overview
38
39
39
-
The AccessControl module provides a robust system for managing roles and permissions within a Compose diamond. It allows for granular control over who can perform specific actions by assigning roles to accounts. This enhances security and enables composability by defining clear access boundaries for different functionalities.
40
+
The AccessControl module provides a robust system for managing roles and permissions within a Compose diamond. It allows for granular control over which accounts can perform specific actions by assigning them roles. This is crucial for maintaining security and ensuring that only authorized entities can interact with sensitive functions.
- Use `requireRole` to enforce access control checks directly within facet functions, reverting with `AccessControlUnauthorizedAccount`if the caller lacks the necessary role.
431
-
-Understand that roles are managed by their designated admin role; ensure the admin role itself is properly secured.
432
-
-When revoking roles, be mindful of the implications for ongoing operations that may rely on that role.
430
+
- Use `requireRole` to enforce access control checks directly within facet functions, reverting with `AccessControlUnauthorizedAccount`on failure.
431
+
-Define custom roles and manage their admin roles using `setRoleAdmin` to maintain a clear hierarchy and control over role assignments.
432
+
-Ensure the AccessControl module is initialized with appropriate default admin roles during diamond deployment.
433
433
</Callout>
434
434
435
435
## Integration Notes
436
436
437
437
<Callouttype="success"title="Shared Storage">
438
-
The AccessControl module stores its state within the diamond's storage. Facets interacting with AccessControl should use the `IAccessControl`interface. Functions like `grantRole`, `revokeRole`, and `setRoleAdmin` modify the access control state, which is immediately visible to all facets upon upgrade. The module relies on the diamond's underlying address to function.
438
+
The AccessControl module stores its state within the diamond's storage. Facets interact with this module via its interface. The `getStorage()` function provides direct access to the module's internal storage struct, which contains mappings for roles, role admins, and account role assignments. Any changes made to role assignments or admin roles through the AccessControl module's functions are immediately reflected and accessible to all facets interacting with the diamond.
0 commit comments