首页 > 解决方案 > 从交易中更新 Hyperledger ACL

问题描述

我有UserBuyer参与者在网络上。通常,买家无法READ获取用户的数据,但我想进行GrantAccess交易RevokeAccess,因此Users 可以选择授予和撤销s的READ访问权限Buyer

我一直无法找到有关如何执行此操作的任何信息,将不胜感激。

标签: blockchainhyperledgerhyperledger-composer

解决方案


您将运行一个“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 等的功能。


推荐阅读