【问题标题】:Transactions to authorize/revoke READ access to transaction initiator's assets in Hyperledger Composer ACL授权/撤销对 Hyperledger Composer ACL 中交易发起者资产的 READ 访问权限的交易
【发布时间】:2018-03-12 16:55:55
【问题描述】:

在 Hyperledger Composer github 上,他们提供了一个带有可选事务子句的条件 ACL 脚本示例。在他们提供的示例中,它是对资产所有者和交易发起者的操作访问权限。

规则 SampleConditionalRuleWithTransaction { description: "ACL 规则的描述" 参与者(m):“org.example.SampleParticipant” 操作:读取、创建、更新 资源(v):“org.example.SampleAsset” 交易(tx):“org.example.SampleTransaction” 条件:(v.owner.getIdentifier() == m.getIdentifier()) 行动:允许 }

如果我希望交易的“接收方”获得对交易发起方资产的读取权限,该怎么办?例如,授权或撤销监管机构对交易发起人(所有者/参与者)资产的读取权限的参与者交易。

感谢您提供的任何帮助!

【问题讨论】:

  • 您是否看过更详细地介绍 ACL 的教程? hyperledger.github.io/composer/next/tutorials/acl-trading.html 请注意,此文档位于文档的“下一个”流中,即 Composer v0.18.*,但它应该可以与“最新”流中的 composer v0.16.* 一起使用。
  • 我没见过这个。您链接中的权限示例并没有解决我正在寻找的内容。我知道我可以为监管者参与者设置更持久的权限,但想要一个由资产所有者/参与者通过交易授予和撤销的权限。非常感谢您的回复!

标签: hyperledger-composer


【解决方案1】:

在资产定义中,您可以有一个字段、allowed_viewer 字段,并基于此定义规则来查看资产

示例 在cto文件中,

asset Commodity identified by tradingSymbol {
  o String tradingSymbol
  o String description
  o String mainExchange
  o Double quantity
  o Trader[] allowed_viewer
  --> Trader owner
}

在acl文件中

rule R1a_Traderview {
  description: "Everyone in allowed_viewer can view"
  participant(p): "org.example.trading.Trader"
  operation: READ
  resource(r): "org.example.trading.Commodity"
  condition: (r.allowed_viewer.indexOf(p.getIdentifier())>=0)
  action: ALLOW
}

【讨论】: