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
Manages role-based access control within a diamond.
24
+
Manages roles and permissions within the diamond.
25
25
</DocSubtitle>
26
26
27
27
<Callouttype="info"title="Key Features">
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.
28
+
- Hierarchical role management with role admins.
29
+
- Support for granting and revoking roles to individual accounts or in batches.
30
+
- Built-in check functions (`hasRole`, `requireRole`) for easy permission verification.
31
+
- Renounce role functionality for accounts to give up their own permissions.
31
32
</Callout>
32
33
33
34
## Overview
34
35
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.
36
+
The AccessControlFacet provides a robust role-based access control (RBAC) system for Compose diamonds. It allows for granular permission management, enabling administrators to grant, revoke, and renounce roles for specific accounts. This facet is crucial for securing administrative functions and controlling access to sensitive operations within the diamond.
-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.
507
+
-Ensure the `DEFAULT_ADMIN_ROLE` is granted to the initial deployer or multisig for diamond ownership.
508
+
-Use role hierarchies by setting role admins appropriately to delegate permission management.
509
+
-Batch role grants and revokes (`grantRoleBatch`, `revokeRoleBatch`) for gas efficiency when managing multiple accounts.
519
510
</Callout>
520
511
521
512
## Security Considerations
522
513
523
514
<Callouttype="warning"title="Security">
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`.
515
+
Access control checks are enforced at the function level. Ensure that callers attempting to manage roles (grant, revoke, set admin) possess the necessary administrative privileges for the target role. Reentrancy is not a direct concern for role management functions, but ensure that any functions that *grant* roles do not have reentrancy vulnerabilities if they call external contracts. All role operations are protected against unauthorized callers via `AccessControlUnauthorizedAccount` and `AccessControlUnauthorizedSender` errors.
Copy file name to clipboardExpand all lines: website/docs/library/access/AccessControl/AccessControlMod.mdx
+22-23Lines changed: 22 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,8 @@ 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
-
- 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.
29
+
- Functions to grant, revoke, and check role assignments for accounts.
30
+
- Ability to define and manage administrative roles for other roles.
32
31
</Callout>
33
32
34
33
<Callouttype="info"title="Module Usage">
@@ -37,7 +36,7 @@ This module provides internal functions for use in your custom facets. Import it
37
36
38
37
## Overview
39
38
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.
39
+
The AccessControl module provides a robust system for managing roles and permissions within your Compose diamond. It allows you to define granular access levels for different accounts, ensuring that only authorized entities can perform sensitive operations. This module is crucial for building secure and auditable decentralized applications.
- 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.
429
+
- Use `requireRole`for access control checks to ensure correct authorization before executing critical functions.
430
+
- Define custom roles using `keccak256` for specific functionalities and manage their assignments and admin roles effectively.
431
+
-Be mindful of role administration: ensure the `DEFAULT_ADMIN_ROLE` is secured and `setRoleAdmin` is used judiciously.
433
432
</Callout>
434
433
435
434
## Integration Notes
436
435
437
436
<Callouttype="success"title="Shared Storage">
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.
437
+
The AccessControl module stores its state within the diamond's storage. Facets interact with it by calling its external functions via the diamond proxy address. Ensure the AccessControl facet is correctly initialized within the diamond's deployment process. Any changes to role assignments or admin roles made through this moduleare immediately reflected across all facets interacting with the diamond.
0 commit comments