There is a contract in near-plugins/tests/contracts/access_controllable which shows how to use the plugin. In integration test near-plugins/tests/access_controllable.rs the contract is compiled, deployed and transactions are sent to it (all via workspaces-rs).
# Command to execute the tests:
cargo test --test access_controllable
Note: If this doesn't compile, #6 should fix it.
Overview
The contract developer specifies an enum whose variants represent roles.
The developer derives AccessControlRole for that enum. It defines a bitflag type that encodes permissions and implements helpers for the conversion between roles (i.e. variants of the enum) and bitflags.
The contract itself gets the attribute #[access_control] which injects the structure that manages permissions into the contract.
The developer can then use functions and attributes to interact with Acl, e.g.
This PR adds the basics for Acl and the contract and integration test mentioned above ensure that everything is wired together correctly. Upcoming PRs will add functionality to make this plugin feature equivalent to OpenZeppelin Access Control.
The target branch is acl (instead of master) since there will be more PRs on top of this.
Acl: Access control lists
This PR adds building blocks for an Acl plugin, inspired by OpenZeppelin Access Control.
There is a contract in
near-plugins/tests/contracts/access_controllable
which shows how to use the plugin. In integration testnear-plugins/tests/access_controllable.rs
the contract is compiled, deployed and transactions are sent to it (all viaworkspaces-rs
).Note: If this doesn't compile, #6 should fix it.
Overview
AccessControlRole
for that enum. It defines a bitflag type that encodes permissions and implements helpers for the conversion between roles (i.e. variants of the enum) and bitflags.#[access_control]
which injects the structure that manages permissions into the contract.self.acl_has_role(role, account_id)
)#[access_control_any(roles(Role::LevelA, Role::LevelB)])
Roadmap
This PR adds the basics for Acl and the contract and integration test mentioned above ensure that everything is wired together correctly. Upcoming PRs will add functionality to make this plugin feature equivalent to OpenZeppelin Access Control.
The target branch is
acl
(instead of master) since there will be more PRs on top of this.