https://github.com/zacksleo/substrate-rbac
substrate v3 rbac pallet
https://github.com/zacksleo/substrate-rbac
Last synced: about 1 year ago
JSON representation
substrate v3 rbac pallet
- Host: GitHub
- URL: https://github.com/zacksleo/substrate-rbac
- Owner: zacksleo
- License: apache-2.0
- Created: 2021-07-25T11:57:23.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-12T12:36:02.000Z (almost 5 years ago)
- Last Synced: 2025-02-07T13:47:45.547Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Substrate Role-based Access Control Pallet
A [Substrate](https://github.com/paritytech/substrate) pallet implementing role-based access control and permissions for Substrate extrinsic calls.
The filtering of incoming extrinsics and their sender accounts is done at the transaction queue validation layer, using the `SignedExtension` trait.
## Usage
* Add the module's dependency in the `Cargo.toml` of your `runtime` directory. Make sure to enter the correct path or git url of the pallet as per your setup.
```toml
[dependencies.substrate_rbac]
package = 'substrate-rbac'
git = 'https://github.com/gautamdhameja/substrate-rbac.git'
default-features = false
```
* Declare the pallet in your `runtime/src/lib.rs`.
```rust
pub use substrate_rbac;
impl substrate_rbac::Trait for Runtime {
type Event = Event;
}
construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
...
...
...
RBAC: substrate_rbac::{Module, Call, Storage, Event, Config},
}
);
```
* Add the module's `Authorize` type in the `SignedExtra` checklist.
```rust
pub type SignedExtra = (
...
...
balances::TakeFees,
substrate_rbac::Authorize
```
* Add a genesis configuration for the module in the `src/chain_spec.rs` file.
```rust
rbac: Some(RBACConfig {
super_admins: vec![get_account_id_from_seed::("Alice")]
})
```
* `cargo build --release` and then `cargo run --release -- --dev`
## Sample
The usage of this pallet are demonstrated in the [Substrate permissioning sample](https://github.com/gautamdhameja/substrate-permissioning).
## Disclaimer
This code not audited and reviewed for production use cases. You can expect bugs and security vulnerabilities. Do not use it as-is in real applications.