hc_roles_mixin
Generic holochain mixin to include administrator and dynamic roles in any holochain application, using the progenitor pattern.
This mixin is built to target hc v0.0.42-alpha3
. It also depends on the holochain_anchors to be present and configured.
Known issue: due to updated entries not being propagated, this mixin won't actually work in a real environtment, since it depends on an update on the role entry to be propagated througout the network.
Design
Here is the design for this mixin: https://hackmd.io/6xfwfSVYSGeZe3vQ_-1cWw?view.
Documentation
Here you can find the documentation for this mixin: https://docs.rs/hc_roles_mixin.
Installation
Add the following to your zomes cargo toml.
holochain_anchors = "0.2.1"
hc_roles_mixin = "0.1.3"
Usage
Setup
Add the anchor entry definition to your zome.
Add the roles entry definition to your zome.
In your init
function, create the Admin
role:
Create a role
To create a role, simply call the create_role
function:
Assign a role
To assign a role, simply call the assign_role
function:
Check if user has a certain role
To check if a user has a certain role, you can use the validation has_agent_role
function:
validation:
Unassign a role
To unassign a role, simply call the unassign_role
function: