blockchain - 从交易中更新 Hyperledger ACL
问题描述
我有User
和Buyer
参与者在网络上。通常,买家无法READ
获取用户的数据,但我想进行GrantAccess
交易RevokeAccess
,因此User
s 可以选择授予和撤销s的READ
访问权限Buyer
我一直无法找到有关如何执行此操作的任何信息,将不胜感激。
解决方案
您将运行一个“tx_GrantAccess”事务,首先更新特定买家的记录(例如,id买家 123 - 一个使用名为 的字段建模的参与者,该字段由该事务access
设置)。true
我可以在目标买家记录(资源)上使用条件匹配(作为布尔值),如果买家,比如说buyer123(即正在访问业务网络),access=true
那么他可以读取用户记录。
事务规则(User
访问事务类所需的)
rule rule_1 {
description: "grant access to User, for the 2 x Transactions themselves"
participant: "org.acme.example.User"
operation: CREATE
resource: "org.acme.example.tx_*"
action: ALLOW
}
用户访问规则:
rule rule_2 {
description: "if granted access, allow READ of User by buyer"
participant(m): "org.acme.example.Buyer"
operation: READ
resource(v): "org.acme.example.User"
condition: (m.access)
action: ALLOW
}
哪里Buyer
有一个字段(例如。
participant Buyer identified by id {
o String id
o Boolean access default=false
}
并且您的交易tx_GrantAccess
具有将access
在特定买方记录上设置为 truetx_RevokeAccess
并将其设置为 false 等的功能。
推荐阅读
- python - 为什么我在 python 上的全局声明之前得到“变量分配”
- datetime - 绘图仪只绘制时间,而不是日期
- django - social-auth-app-django 如何与 jinja2 一起工作?
- php - php 变量 - 将变量传递到另一个 php 页面的最佳方式
- python-3.x - tribonacci序列python代码在while循环中跳过for循环
- c++ - 如何从另一个顶点中减去一个顶点?
- python - 在 Python 中生成 YubiOTP 验证 HMAC-SHA-1 签名
- c - 为什么这个结果出现在 for 语句中?
- php - 发送电子邮件后页面未在 PHP 中正确加载
- c++ - 是否可以将枚举类成员标记为已弃用?