-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {IAccessControlModule} from '../interfaces/modules/accessControl/IAccessControlModule.sol'; | ||
|
||
abstract contract AccessController { | ||
/** | ||
* @notice The access control struct | ||
* @param user The address of the user | ||
* @param data The data for access control validation | ||
*/ | ||
struct AccessControl { | ||
address user; | ||
bytes data; | ||
} | ||
|
||
/** | ||
* @notice Modifier to check if the caller has access to the user | ||
* @param _caller The caller of the function | ||
* @param _user The user to check access for | ||
* @param _data The data to check access for | ||
*/ | ||
modifier hasAccess(IAccessControlModule _accessControlModule, address _caller, AccessControl memory _accessControl) { | ||
if ( | ||
_caller == _accessControl.user | ||
|| ( | ||
address(_accessControlModule) != address(0) | ||
&& _accessControlModule.hasAccess(_caller, _accessControl.user, _accessControl.data) | ||
) | ||
) revert AccessController_NoAccess(); | ||
_; | ||
} | ||
} |
This file contains 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
This file contains 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
12 changes: 12 additions & 0 deletions
12
solidity/interfaces/modules/accessControl/IAccessControlModule.sol
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {IModule} from '../../IModule.sol'; | ||
|
||
/** | ||
* @title ResponseModule | ||
* @notice Common interface for all response modules | ||
*/ | ||
interface IAccessControlModule is IModule { | ||
function hasAccess(address _caller, address _user, bytes calldata _data) external view returns (bool _hasAccess); | ||
} |