Authorization
Contains interfaces and contracts related to authorization.
Contracts
IAuthorization
import "@etherisc/gif-next/contracts/authorization/IAuthorization.sol";
-
[
getTokenHandlerName()
] -
[
getTokenHandlerTarget()
] -
[
getTargets()
] -
[
targetExists(target)
]
-
[
getDomain()
] -
[
getRelease()
] -
[
getCommitHash()
] -
[
getMainTargetName()
] -
[
getMainTarget()
] -
[
getServiceDomains()
] -
[
getServiceDomain(idx)
] -
[
getServiceTarget(serviceDomain)
] -
[
getServiceRole(serviceDomain)
] -
[
getServiceAddress(serviceDomain)
] -
[
getTargetRole(target)
] -
[
roleExists(roleId)
] -
[
getRoles()
] -
[
getRoleInfo(roleId)
] -
[
getRoleName(roleId)
] -
[
getAuthorizedRoles(target)
] -
[
getAuthorizedFunctions(target, roleId)
]
-
[
supportsInterface(interfaceId)
]
getTokenHandlerName() → string name
external
Returns the token hander name. Only components have a token handler.
IServiceAuthorization
import "@etherisc/gif-next/contracts/authorization/IServiceAuthorization.sol";
-
[
getDomain()
] -
[
getRelease()
] -
[
getCommitHash()
] -
[
getMainTargetName()
] -
[
getMainTarget()
] -
[
getServiceDomains()
] -
[
getServiceDomain(idx)
] -
[
getServiceTarget(serviceDomain)
] -
[
getServiceRole(serviceDomain)
] -
[
getServiceAddress(serviceDomain)
] -
[
getTargetRole(target)
] -
[
roleExists(roleId)
] -
[
getRoles()
] -
[
getRoleInfo(roleId)
] -
[
getRoleName(roleId)
] -
[
getAuthorizedRoles(target)
] -
[
getAuthorizedFunctions(target, roleId)
]
-
[
supportsInterface(interfaceId)
]
getRelease() → VersionPart release
external
Returns the release (VersionPart) for which the authorizations are defined by this contract. Matches with the release returned by the linked service authorization.
getMainTargetName() → string name
external
Returns the main target id name as string. This name is used to derive the target id and a corresponding target role name Overwrite this function to change the basic pool target name.
getServiceDomains() → ObjectType[] serviceDomains
external
Returns the full list of service domains for this release. Services need to be registered for the release in revers order of this list.
getServiceDomain(uint256 idx) → ObjectType serviceDomain
external
Returns the service domain for the provided index.
getServiceTarget(ObjectType serviceDomain) → Str serviceTarget
external
Returns the service target for the specified domain.
getServiceRole(ObjectType serviceDomain) → RoleId serviceRoleId
external
Returns the service target for the specified domain.
getServiceAddress(ObjectType serviceDomain) → address service
external
Returns the expected service address for the provided domain.
getTargetRole(Str target) → RoleId roleId
external
Returns the role id associated with the target. If no role is associated with the target the zero role id is returned.
getRoleInfo(RoleId roleId) → struct IAccess.RoleInfo roleInfo
external
Returns the role info for the provided role id.
IAccessAdmin
import "@etherisc/gif-next/contracts/authorization/IAccessAdmin.sol";
Base interface for registry admin, release admin, and instance admin
-
[
getAuthorization()
] -
[
getLinkedNftId()
] -
[
isLocked()
] -
[
roles()
] -
[
getRoleId(idx)
] -
[
roleExists(roleId)
] -
[
getRoleForName(name)
] -
[
getRoleInfo(roleId)
] -
[
isRoleActive(roleId)
] -
[
isRoleCustom(roleId)
] -
[
isRoleMember(roleId, account)
] -
[
isRoleAdmin(roleId, account)
] -
[
roleMembers(roleId)
] -
[
getRoleMember(roleId, idx)
] -
[
targetExists(target)
] -
[
getTargetForName(name)
] -
[
targets()
] -
[
getTargetAddress(idx)
] -
[
getTargetInfo(target)
] -
[
isTargetLocked(target)
] -
[
authorizedFunctions(target)
] -
[
getAuthorizedFunction(target, idx)
]
-
[
getRelease()
]
-
[
getRegistry()
]
-
[
authority()
] -
[
setAuthority()
] -
[
isConsumingScheduledOp()
]
-
[
LogAccessAdminRoleCreated(admin, roleId, targetType, roleAdminId, name)
] -
[
LogAccessAdminTargetCreated(admin, name, managed, target, roleId)
] -
[
LogAccessAdminRoleActivatedSet(admin, roleId, active, lastUpdateIn)
] -
[
LogAccessAdminRoleGranted(admin, account, roleName)
] -
[
LogAccessAdminRoleRevoked(admin, account, roleName)
] -
[
LogAccessAdminTargetLockedSet(admin, target, locked, lastUpdateIn)
] -
[
LogAccessAdminFunctionGranted(admin, target, func, lastUpdateIn)
]
-
[
AuthorityUpdated(authority)
]
getAuthorizedFunction(address target, uint256 idx) → struct IAccess.FunctionInfo func, RoleId roleId
external
LogAccessAdminRoleCreated(string admin, RoleId roleId, enum IAccess.TargetType targetType, RoleId roleAdminId, string name)
event
LogAccessAdminTargetCreated(string admin, string name, bool managed, address target, RoleId roleId)
event
LogAccessAdminRoleActivatedSet(string admin, RoleId roleId, bool active, Blocknumber lastUpdateIn)
event
AccessAdmin
import "@etherisc/gif-next/contracts/authorization/AccessAdmin.sol";
A generic access amin contract that implements role based access control based on OpenZeppelin’s AccessManager contract. The contract provides read functions to query all available roles, targets and access rights. This contract works for both a constructor based deployment or a deployment based on cloning and initialization.
-
[
initialize(authority, adminName)
] -
[
__AccessAdmin_init(authority, adminName)
] -
[
getRelease()
] -
[
getRegistry()
] -
[
getLinkedNftId()
] -
[
getAuthorization()
] -
[
isLocked()
] -
[
roles()
] -
[
getRoleId(idx)
] -
[
getAdminRole()
] -
[
getPublicRole()
] -
[
roleExists(roleId)
] -
[
getRoleForName(name)
] -
[
getRoleInfo(roleId)
] -
[
isRoleActive(roleId)
] -
[
isRoleCustom(roleId)
] -
[
roleMembers(roleId)
] -
[
getRoleMember(roleId, idx)
] -
[
isRoleMember(roleId, account)
] -
[
isRoleAdmin(roleId, account)
] -
[
targetExists(target)
] -
[
targets()
] -
[
getTargetAddress(idx)
] -
[
getTargetInfo(target)
] -
[
getTargetForName(name)
] -
[
isTargetLocked(target)
] -
[
authorizedFunctions(target)
] -
[
getAuthorizedFunction(target, idx)
] -
[
getFunctionInfo(target, selector)
] -
[
_linkToNftOwnable(registerable)
] -
[
_createRoles(authorization)
] -
[
_createRole(roleId, info, revertOnExistingRole)
] -
[
_setRoleActive(roleId, active)
] -
[
_grantRoleToAccount(roleId, account)
] -
[
_revokeRoleFromAccount(roleId, account)
] -
[
_getOrCreateTargetRoleIdAndName(target, targetName, targetType)
] -
[
_createTarget(target, targetName, targetType, checkAuthority)
] -
[
_createTargetUnchecked(target, targetName, targetType, managed)
] -
[
_setTargetLocked(target, locked)
] -
[
_authorizeFunctions(authorization, target, roleId)
] -
[
_authorizeTargetFunctions(target, roleId, functions, onlyComponentOrContractTargets, addFunctions)
] -
[
_updateFunctionAccess(target, roleId, func, addFunction)
]
-
[
__AccessManaged_init(initialAuthority)
] -
[
__AccessManaged_init_unchained(initialAuthority)
] -
[
authority()
] -
[
setAuthority(newAuthority)
] -
[
isConsumingScheduledOp()
] -
[
_setAuthority(newAuthority)
] -
[
_checkCanCall(caller, data)
]
-
[
__Context_init()
] -
[
__Context_init_unchained()
] -
[
_msgSender()
] -
[
_msgData()
] -
[
_contextSuffixLength()
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
LogAccessAdminRoleCreated(admin, roleId, targetType, roleAdminId, name)
] -
[
LogAccessAdminTargetCreated(admin, name, managed, target, roleId)
] -
[
LogAccessAdminRoleActivatedSet(admin, roleId, active, lastUpdateIn)
] -
[
LogAccessAdminRoleGranted(admin, account, roleName)
] -
[
LogAccessAdminRoleRevoked(admin, account, roleName)
] -
[
LogAccessAdminTargetLockedSet(admin, target, locked, lastUpdateIn)
] -
[
LogAccessAdminFunctionGranted(admin, target, func, lastUpdateIn)
]
-
[
AuthorityUpdated(authority)
]
-
[
Initialized(version)
]
initialize(address authority, string adminName)
public
Initializes this admin with the provided accessManager (and authorization specification). Internally initializes access manager with this admin and creates basic role setup.
__AccessAdmin_init(address authority, string adminName)
internal
Initializes this admin with the provided accessManager and name. IMPORTANT - cloning of an access admin and initialization MUST be done in the same tx. - this function as well as any completeSetup functions MUST be called in the same tx.
getRelease() → VersionPart release
public
Registers a registry contract for a specified chain. Only one chain registry may be registered per chain
getAuthorizedFunction(address target, uint256 idx) → struct IAccess.FunctionInfo func, RoleId roleId
external
getFunctionInfo(address target, Selector selector) → struct IAccess.FunctionInfo functionInfo
external
_createRole(RoleId roleId, struct IAccess.RoleInfo info, bool revertOnExistingRole)
internal
Creates a role based on the provided parameters. Checks that the provided role and role id and role name not already used.
_setRoleActive(RoleId roleId, bool active)
internal
Activates or deactivates role. The role activ property is indirectly controlled over the pausedAt timestamp.
_grantRoleToAccount(RoleId roleId, address account)
internal
grant the specified role to the provided account
_revokeRoleFromAccount(RoleId roleId, address account)
internal
revoke the specified role from the provided account
_getOrCreateTargetRoleIdAndName(address target, string targetName, enum IAccess.TargetType targetType) → RoleId roleId, string roleName, bool exists
internal
_createTarget(address target, string targetName, enum IAccess.TargetType targetType, bool checkAuthority) → RoleId contractRoleId
internal
_createTargetUnchecked(address target, string targetName, enum IAccess.TargetType targetType, bool managed) → RoleId targetRoleId
internal
Creates a new target and a corresponding contract role. The function assigns the role to the target and logs the creation.
_authorizeFunctions(contract IAuthorization authorization, Str target, RoleId roleId)
internal
Authorize the functions of the target for the specified role.
AccessManagerCloneable
import "@etherisc/gif-next/contracts/authorization/AccessManagerCloneable.sol";
An AccessManager based on OpenZeppelin that is cloneable and has a central lock property. The lock property allows to lock all services of a release in a central place. Cloned by upon release preparation and instance cloning.
-
[
initialize(admin)
] -
[
completeSetup(registry, release)
] -
[
canCall(caller, target, selector)
] -
[
setLocked(locked)
] -
[
getRelease()
] -
[
isLocked()
] -
[
_checkAndSetRelease(release)
] -
[
_checkAndSetRegistry(registry)
]
-
[
__RegistryLinked_init(registry)
] -
[
getRegistry()
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
__AccessManager_init(initialAdmin)
] -
[
__AccessManager_init_unchained(initialAdmin)
] -
[
expiration()
] -
[
minSetback()
] -
[
isTargetClosed(target)
] -
[
getTargetFunctionRole(target, selector)
] -
[
getTargetAdminDelay(target)
] -
[
getRoleAdmin(roleId)
] -
[
getRoleGuardian(roleId)
] -
[
getRoleGrantDelay(roleId)
] -
[
getAccess(roleId, account)
] -
[
hasRole(roleId, account)
] -
[
labelRole(roleId, label)
] -
[
grantRole(roleId, account, executionDelay)
] -
[
revokeRole(roleId, account)
] -
[
renounceRole(roleId, callerConfirmation)
] -
[
setRoleAdmin(roleId, admin)
] -
[
setRoleGuardian(roleId, guardian)
] -
[
setGrantDelay(roleId, newDelay)
] -
[
_grantRole(roleId, account, grantDelay, executionDelay)
] -
[
_revokeRole(roleId, account)
] -
[
_setRoleAdmin(roleId, admin)
] -
[
_setRoleGuardian(roleId, guardian)
] -
[
_setGrantDelay(roleId, newDelay)
] -
[
setTargetFunctionRole(target, selectors, roleId)
] -
[
_setTargetFunctionRole(target, selector, roleId)
] -
[
setTargetAdminDelay(target, newDelay)
] -
[
_setTargetAdminDelay(target, newDelay)
] -
[
setTargetClosed(target, closed)
] -
[
_setTargetClosed(target, closed)
] -
[
getSchedule(id)
] -
[
getNonce(id)
] -
[
schedule(target, data, when)
] -
[
execute(target, data)
] -
[
cancel(caller, target, data)
] -
[
consumeScheduledOp(caller, data)
] -
[
_consumeScheduledOp(operationId)
] -
[
hashOperation(caller, target, data)
] -
[
updateAuthority(target, newAuthority)
]
-
[
__Multicall_init()
] -
[
__Multicall_init_unchained()
] -
[
multicall(data)
]
-
[
__Context_init()
] -
[
__Context_init_unchained()
] -
[
_msgSender()
] -
[
_msgData()
] -
[
_contextSuffixLength()
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
OperationScheduled(operationId, nonce, schedule, caller, target, data)
] -
[
OperationExecuted(operationId, nonce)
] -
[
OperationCanceled(operationId, nonce)
] -
[
RoleLabel(roleId, label)
] -
[
RoleGranted(roleId, account, delay, since, newMember)
] -
[
RoleRevoked(roleId, account)
] -
[
RoleAdminChanged(roleId, admin)
] -
[
RoleGuardianChanged(roleId, guardian)
] -
[
RoleGrantDelayChanged(roleId, delay, since)
] -
[
TargetClosed(target, closed)
] -
[
TargetFunctionRoleUpdated(target, selector, roleId)
] -
[
TargetAdminDelayUpdated(target, delay, since)
]
-
[
Initialized(version)
]
completeSetup(address registry, VersionPart release)
external
Completes the setup of the access manager. Links the access manager to the registry and sets the release version.
canCall(address caller, address target, bytes4 selector) → bool immediate, uint32 delay
public
Returns true if the caller is authorized to call the target with the given selector and the manager lock is not set to locked. Feturn values as in OpenZeppelin AccessManager. For a locked manager the function reverts with ErrorAccessManagerTargetAdminLocked.
setLocked(bool locked)
external
Locks/unlocks all services of this access manager. Only the corresponding access admin can lock/unlock the services.
Authorization
import "@etherisc/gif-next/contracts/authorization/Authorization.sol";
-
[
constructor(mainTargetName, domain, release, commitHash, targetType, includeTokenHandler)
] -
[
getTokenHandlerName()
] -
[
getTokenHandlerTarget()
] -
[
getTarget(targetName)
] -
[
getTargets()
] -
[
targetExists(target)
] -
[
_setupServiceTargets()
] -
[
_setupTargets()
] -
[
_setupRoles()
] -
[
_setupTokenHandlerAuthorizations()
] -
[
_setupTargetAuthorizations()
] -
[
_addCustomRole(roleId, adminRoleId, maxMemberCount, name)
] -
[
_addGifTarget(contractName)
] -
[
_addInstanceTarget(contractName)
] -
[
_addTarget(name)
] -
[
_toTargetRoleId(targetDomain)
] -
[
_toTargetRoleName(targetName)
]
-
[
getDomain()
] -
[
getRelease()
] -
[
getCommitHash()
] -
[
getMainTargetName()
] -
[
getMainTarget()
] -
[
getServiceDomains()
] -
[
getServiceDomain(idx)
] -
[
getServiceTarget(serviceDomain)
] -
[
getServiceRole(serviceDomain)
] -
[
getServiceAddress(serviceDomain)
] -
[
getTargetRole(target)
] -
[
roleExists(roleId)
] -
[
getRoles()
] -
[
getRoleInfo(roleId)
] -
[
getRoleName(roleId)
] -
[
getAuthorizedRoles(target)
] -
[
getAuthorizedFunctions(target, roleId)
] -
[
_setupDomains()
] -
[
_setupDomainAuthorizations()
] -
[
_authorizeServiceDomain(serviceDomain, serviceAddress)
] -
[
_addTargetWithRole(targetName, roleId, roleName)
] -
[
_addRole(roleId, info)
] -
[
_authorizeForService(serviceDomain, authorizedDomain)
] -
[
_authorizeForTarget(target, authorizedRoleId)
] -
[
_authorize(functions, selector, name)
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
Initialized(version)
]
constructor(string mainTargetName, ObjectType domain, uint8 release, string commitHash, enum IAccess.TargetType targetType, bool includeTokenHandler)
public
getTokenHandlerName() → string
public
Returns the token hander name. Only components have a token handler.
getTokenHandlerTarget() → Str
public
Returns the token hander target. Only components have a token handler.
_setupServiceTargets()
internal
Sets up the relevant service targets for the component. Overwrite this function for use case specific authorizations.
_setupTargets()
internal
Sets up the relevant (non-service) targets for the component. Overwrite this function for use case specific authorizations.
_setupRoles()
internal
Sets up the relevant roles for the component. Overwrite this function for use case specific authorizations.
_setupTokenHandlerAuthorizations()
internal
Sets up the relevant component’s token handler authorizations. Overwrite this function for use case specific authorizations.
_setupTargetAuthorizations()
internal
Sets up the relevant target authorizations for the component. Overwrite this function for use case specific authorizations.
_addCustomRole(RoleId roleId, RoleId adminRoleId, uint32 maxMemberCount, string name)
internal
Add a contract role for the provided role id and name.
_addInstanceTarget(string contractName)
internal
Add an instance target with its corresponding contract role
ServiceAuthorization
import "@etherisc/gif-next/contracts/authorization/ServiceAuthorization.sol";
Base contract for release specific service authorization contracts and for Authorization contracts.
-
[
constructor(mainTargetName, domain, release, commitHash)
] -
[
getDomain()
] -
[
getRelease()
] -
[
getCommitHash()
] -
[
getMainTargetName()
] -
[
getMainTarget()
] -
[
getServiceDomains()
] -
[
getServiceDomain(idx)
] -
[
getServiceTarget(serviceDomain)
] -
[
getServiceRole(serviceDomain)
] -
[
getServiceAddress(serviceDomain)
] -
[
getTargetRole(target)
] -
[
roleExists(roleId)
] -
[
getRoles()
] -
[
getRoleInfo(roleId)
] -
[
getRoleName(roleId)
] -
[
getAuthorizedRoles(target)
] -
[
getAuthorizedFunctions(target, roleId)
] -
[
_setupDomains()
] -
[
_setupDomainAuthorizations()
] -
[
_authorizeServiceDomain(serviceDomain, serviceAddress)
] -
[
_addTargetWithRole(targetName, roleId, roleName)
] -
[
_addRole(roleId, info)
] -
[
_authorizeForService(serviceDomain, authorizedDomain)
] -
[
_authorizeForTarget(target, authorizedRoleId)
] -
[
_authorize(functions, selector, name)
]
-
[
__ERC165_init()
] -
[
_initializeERC165()
] -
[
_registerInterface(interfaceId)
] -
[
_registerInterfaceNotInitializing(interfaceId)
] -
[
supportsInterface(interfaceId)
]
-
[
_checkInitializing()
] -
[
_disableInitializers()
] -
[
_getInitializedVersion()
] -
[
_isInitializing()
]
-
[
Initialized(version)
]
getRelease() → VersionPart release
public
Returns the release (VersionPart) for which the authorizations are defined by this contract. Matches with the release returned by the linked service authorization.
getMainTargetName() → string name
public
Returns the main target id name as string. This name is used to derive the target id and a corresponding target role name Overwrite this function to change the basic pool target name.
getServiceDomains() → ObjectType[] serviceDomains
external
Returns the full list of service domains for this release. Services need to be registered for the release in revers order of this list.
getServiceDomain(uint256 idx) → ObjectType serviceDomain
external
Returns the service domain for the provided index.
getServiceTarget(ObjectType serviceDomain) → Str target
public
Returns the service target for the specified domain.
getServiceRole(ObjectType serviceDomain) → RoleId serviceRoleId
public
Returns the service target for the specified domain.
getServiceAddress(ObjectType serviceDomain) → address service
external
Returns the expected service address for the provided domain.
getTargetRole(Str target) → RoleId roleId
public
Returns the role id associated with the target. If no role is associated with the target the zero role id is returned.
getRoleInfo(RoleId roleId) → struct IAccess.RoleInfo info
external
Returns the role info for the provided role id.
getAuthorizedRoles(Str target) → RoleId[] roleIds
external
For the given target the list of authorized role ids is returned
getAuthorizedFunctions(Str target, RoleId roleId) → struct IAccess.FunctionInfo[] authorizatedFunctions
external
For the given target and role id the list of authorized functions is returned
_setupDomains()
internal
Defines service domains relevant for the authorization. When used for ReleaseAdmin the list defines the services to be registered for the release. IMPORTANT: Both the list of the service domains as well as the ordering of the domains is important. Trying to register services not in this list or register services in a different order will result in an error.
_authorizeServiceDomain(ObjectType serviceDomain, address serviceAddress)
internal
Use this method to to add an authorized domain. The services will need to be registered in the order they are added using this function.
_addTargetWithRole(string targetName, RoleId roleId, string roleName)
internal
Use this method to to add an authorized target together with its target role.
_addRole(RoleId roleId, struct IAccess.RoleInfo info)
internal
Use this method to to add an authorized role.
_authorizeForService(ObjectType serviceDomain, ObjectType authorizedDomain) → struct IAccess.FunctionInfo[] authorizatedFunctions
internal
Use this method to authorize the specified domain to access the service domain.