@@ -10,17 +10,17 @@ import {SetHelper} from "../libs/arrays/SetHelper.sol";
1010import {StringSet} from "../libs/data-structures/StringSet.sol " ;
1111
1212/**
13- * @notice The Role Based Access Control (RBAC) module
13+ * @notice The Role Based Access Control (RBAC) module
1414 *
15- * This is advanced module that handles role management for huge systems. One can declare specific permissions
16- * for specific resources (contracts) and aggregate them into roles for further assignment to users.
15+ * This is advanced module that handles role management for huge systems. One can declare specific permissions
16+ * for specific resources (contracts) and aggregate them into roles for further assignment to users.
1717 *
18- * Each user can have multiple roles and each role can manage multiple resources. Each resource can posses a set of
19- * permissions (CREATE, DELETE) that are only valid for that specific resource.
18+ * Each user can have multiple roles and each role can manage multiple resources. Each resource can posses a set of
19+ * permissions (CREATE, DELETE) that are only valid for that specific resource.
2020 *
21- * The RBAC model supports antipermissions as well. One can grant antipermissions to users to restrict their access level.
22- * There also is a special wildcard symbol "*" that means "everything". This symbol can be applied either to the
23- * resources or permissions.
21+ * The RBAC model supports antipermissions as well. One can grant antipermissions to users to restrict their access level.
22+ * There also is a special wildcard symbol "*" that means "everything". This symbol can be applied either to the
23+ * resources or permissions.
2424 */
2525abstract contract RBAC is IRBAC , Initializable {
2626 using StringSet for StringSet.Set;
@@ -55,16 +55,16 @@ abstract contract RBAC is IRBAC, Initializable {
5555 }
5656
5757 /**
58- * @notice The init function
58+ * @notice The init function
5959 */
6060 function __RBAC_init () internal onlyInitializing {
6161 _addPermissionsToRole (MASTER_ROLE, ALL_RESOURCE, ALL_PERMISSION.asSingletonArray (), true );
6262 }
6363
6464 /**
65- * @notice The function to grant roles to a user
66- * @param to_ the user to grant roles to
67- * @param rolesToGrant_ roles to grant
65+ * @notice The function to grant roles to a user
66+ * @param to_ the user to grant roles to
67+ * @param rolesToGrant_ roles to grant
6868 */
6969 function grantRoles (
7070 address to_ ,
@@ -76,9 +76,9 @@ abstract contract RBAC is IRBAC, Initializable {
7676 }
7777
7878 /**
79- * @notice The function to revoke roles
80- * @param from_ the user to revoke roles from
81- * @param rolesToRevoke_ the roles to revoke
79+ * @notice The function to revoke roles
80+ * @param from_ the user to revoke roles from
81+ * @param rolesToRevoke_ the roles to revoke
8282 */
8383 function revokeRoles (
8484 address from_ ,
@@ -90,10 +90,10 @@ abstract contract RBAC is IRBAC, Initializable {
9090 }
9191
9292 /**
93- * @notice The function to add resource permission to role
94- * @param role_ the role to add permissions to
95- * @param permissionsToAdd_ the array of resources and permissions to add to the role
96- * @param allowed_ indicates whether to add permissions to an allowlist or disallowlist
93+ * @notice The function to add resource permission to role
94+ * @param role_ the role to add permissions to
95+ * @param permissionsToAdd_ the array of resources and permissions to add to the role
96+ * @param allowed_ indicates whether to add permissions to an allowlist or disallowlist
9797 */
9898 function addPermissionsToRole (
9999 string memory role_ ,
@@ -111,10 +111,10 @@ abstract contract RBAC is IRBAC, Initializable {
111111 }
112112
113113 /**
114- * @notice The function to remove permissions from role
115- * @param role_ the role to remove permissions from
116- * @param permissionsToRemove_ the array of resources and permissions to remove from the role
117- * @param allowed_ indicates whether to remove permissions from the allowlist or disallowlist
114+ * @notice The function to remove permissions from role
115+ * @param role_ the role to remove permissions from
116+ * @param permissionsToRemove_ the array of resources and permissions to remove from the role
117+ * @param allowed_ indicates whether to remove permissions from the allowlist or disallowlist
118118 */
119119 function removePermissionsFromRole (
120120 string memory role_ ,
@@ -132,19 +132,19 @@ abstract contract RBAC is IRBAC, Initializable {
132132 }
133133
134134 /**
135- * @notice The function to get the list of user roles
136- * @param who_ the user
137- * @return roles_ the roles of the user
135+ * @notice The function to get the list of user roles
136+ * @param who_ the user
137+ * @return roles_ the roles of the user
138138 */
139139 function getUserRoles (address who_ ) public view override returns (string [] memory roles_ ) {
140140 return _userRoles[who_].values ();
141141 }
142142
143143 /**
144- * @notice The function to get the permissions of the role
145- * @param role_ the role
146- * @return allowed_ the list of allowed permissions of the role
147- * @return disallowed_ the list of disallowed permissions of the role
144+ * @notice The function to get the permissions of the role
145+ * @param role_ the role
146+ * @return allowed_ the list of allowed permissions of the role
147+ * @return disallowed_ the list of disallowed permissions of the role
148148 */
149149 function getRolePermissions (
150150 string memory role_
@@ -182,13 +182,13 @@ abstract contract RBAC is IRBAC, Initializable {
182182 }
183183
184184 /**
185- * @dev DO NOT call `super.hasPermission(...)` in derived contracts, because this method
186- * handles not 2 but 3 states: NO PERMISSION, ALLOWED, DISALLOWED
187- * @notice The function to check the user's possession of the role
188- * @param who_ the user
189- * @param resource_ the resource the user has to have the permission of
190- * @param permission_ the permission the user has to have
191- * @return isAllowed_ true if the user has the permission, false otherwise
185+ * @dev DO NOT call `super.hasPermission(...)` in derived contracts, because this method
186+ * handles not 2 but 3 states: NO PERMISSION, ALLOWED, DISALLOWED
187+ * @notice The function to check the user's possession of the role
188+ * @param who_ the user
189+ * @param resource_ the resource the user has to have the permission of
190+ * @param permission_ the permission the user has to have
191+ * @return isAllowed_ true if the user has the permission, false otherwise
192192 */
193193 function hasPermission (
194194 address who_ ,
@@ -209,9 +209,9 @@ abstract contract RBAC is IRBAC, Initializable {
209209 }
210210
211211 /**
212- * @notice The internal function to grant roles
213- * @param to_ the user to grant roles to
214- * @param rolesToGrant_ the roles to grant
212+ * @notice The internal function to grant roles
213+ * @param to_ the user to grant roles to
214+ * @param rolesToGrant_ the roles to grant
215215 */
216216 function _grantRoles (address to_ , string [] memory rolesToGrant_ ) internal {
217217 _userRoles[to_].add (rolesToGrant_);
@@ -220,9 +220,9 @@ abstract contract RBAC is IRBAC, Initializable {
220220 }
221221
222222 /**
223- * @notice The internal function to revoke roles
224- * @param from_ the user to revoke roles from
225- * @param rolesToRevoke_ the roles to revoke
223+ * @notice The internal function to revoke roles
224+ * @param from_ the user to revoke roles from
225+ * @param rolesToRevoke_ the roles to revoke
226226 */
227227 function _revokeRoles (address from_ , string [] memory rolesToRevoke_ ) internal {
228228 _userRoles[from_].remove (rolesToRevoke_);
@@ -231,11 +231,11 @@ abstract contract RBAC is IRBAC, Initializable {
231231 }
232232
233233 /**
234- * @notice The internal function to add permission to the role
235- * @param role_ the role to add permissions to
236- * @param resourceToAdd_ the resource to which the permissions belong
237- * @param permissionsToAdd_ the permissions of the resource
238- * @param allowed_ whether to add permissions to the allowlist or the disallowlist
234+ * @notice The internal function to add permission to the role
235+ * @param role_ the role to add permissions to
236+ * @param resourceToAdd_ the resource to which the permissions belong
237+ * @param permissionsToAdd_ the permissions of the resource
238+ * @param allowed_ whether to add permissions to the allowlist or the disallowlist
239239 */
240240 function _addPermissionsToRole (
241241 string memory role_ ,
@@ -253,11 +253,11 @@ abstract contract RBAC is IRBAC, Initializable {
253253 }
254254
255255 /**
256- * @notice The internal function to remove permissions from the role
257- * @param role_ the role to remove permissions from
258- * @param resourceToRemove_ the resource to which the permissions belong
259- * @param permissionsToRemove_ the permissions of the resource
260- * @param allowed_ whether to remove permissions from the allowlist or the disallowlist
256+ * @notice The internal function to remove permissions from the role
257+ * @param role_ the role to remove permissions from
258+ * @param resourceToRemove_ the resource to which the permissions belong
259+ * @param permissionsToRemove_ the permissions of the resource
260+ * @param allowed_ whether to remove permissions from the allowlist or the disallowlist
261261 */
262262 function _removePermissionsFromRole (
263263 string memory role_ ,
@@ -278,11 +278,11 @@ abstract contract RBAC is IRBAC, Initializable {
278278 }
279279
280280 /**
281- * @notice The function to check if the role has the permission
282- * @param role_ the role to search the permission in
283- * @param resource_ the role resource to search the permission in
284- * @param permission_ the permission to search
285- * @return true_ if the role has the permission, false otherwise
281+ * @notice The function to check if the role has the permission
282+ * @param role_ the role to search the permission in
283+ * @param resource_ the role resource to search the permission in
284+ * @param permission_ the permission to search
285+ * @return true_ if the role has the permission, false otherwise
286286 */
287287 function _isAllowed (
288288 string memory role_ ,
@@ -301,11 +301,11 @@ abstract contract RBAC is IRBAC, Initializable {
301301 }
302302
303303 /**
304- * @notice The function to check if the role has the antipermission
305- * @param role_ the role to search the antipermission in
306- * @param resource_ the role resource to search the antipermission in
307- * @param permission_ the antipermission to search
308- * @return true_ if the role has the antipermission, false otherwise
304+ * @notice The function to check if the role has the antipermission
305+ * @param role_ the role to search the antipermission in
306+ * @param resource_ the role resource to search the antipermission in
307+ * @param permission_ the antipermission to search
308+ * @return true_ if the role has the antipermission, false otherwise
309309 */
310310 function _isDisallowed (
311311 string memory role_ ,
0 commit comments