首页 > 解决方案 > 非管理员参与者的超级账本作曲家中的访问控制问题

问题描述

我有一个关于超级账本作曲家访问控制的问题。我已经阅读并使用了Hyperledger Composer v0.19 Hiding Historian in ACL中的说明,但仍然没有成功。我想有以下场景:

  1. 我们在名为“org.example.assets”的命名空间中有不同类型的资产。代码如下

命名空间 org.example.assets

导入 org.example.*

abstract asset exampleAsset identified by Id 
{
 o String Id
 --> exampleParticipant owner
}

asset myAsset extends exampleAsset
{
 o String title 
 o String description
 o String criteriaUrl 
 o String logoUrl
 --> exampleParticipant issuer
}

我希望资产的所有者能够访问它们,而不是其他参与者。示例参与者只是继承 Participant 并放置在 org.example 命名空间中。

  1. 我不希望每个参与者都观看整个历史学家;他/她只能看到他/她自己的交易记录

这是我目前拥有的 permissions.acl 文件

rule Participant_CanAccessOwnAssets {
   description: "owner has full access"
   participant(p): "org.example.exampleParticipant"
   operation: ALL
   resource(r): "org.example.assets.exampleAsset"
   condition: (p.getIdentifier() == r.owner.getIdentifier())
   action: ALLOW
}


rule Participant_CanOnlyReadOwnHistorian {
   description: "each party should be able to read its own record"
   participant(p): "org.example.exampleParticipant"
   operation: READ
   resource(r): "org.hyperledger.composer.system.HistorianRecord"
   condition: (p.getIdentifier() == r.participantInvoking.getIdentifier())
   action: ALLOW
}

rule Participants_DenyAccessToHistorian {
   description: "participants cannot access general historian"
   participant: "org.example.exampleParticipant"
   operation: READ
   resource: "org.hyperledger.composer.system.HistorianRecord"
   action: DENY
}

rule Participant_CanReadNetwork {
   description: "participants can read (connect to) the business network"
   participant: "org.example.exampleParticipant"
   operation: READ
   resource: "org.hyperledger.composer.system.Network"
   action: ALLOW
}


rule NetworkAdminUser {
   description: "Grant business network administrators full access to user resources"
   participant: "org.hyperledger.composer.system.NetworkAdmin"
   operation: ALL
   resource: "**"
   action: ALLOW
}

rule NetworkAdminSystem {
   description: "Grant business network administrators full access to system resources"
   participant: "org.hyperledger.composer.system.NetworkAdmin"
   operation: ALL
   resource: "org.hyperledger.composer.system.**"
   action: ALLOW
 }

我使用我的管理员卡连接到作曲家游乐场,然后创建一个新参与者并为该参与者发出问题和身份。但是当我尝试使用新创建的卡连接到网络时,出现以下错误

Error: transaction returned with failure: AccessException: Participant 'org.pledger.PledgerParticipant#neo' does not have 'READ' access to resource 'org.hyperledger.composer.system.AssetRegistry#org.hyperledger.composer.system.HistorianRecord'

我应该怎么做才能解决这个问题?我猜这个规则关于我正在使用的继承存在问题,概括说从抽象 exampleAsset 继承的任何资产都有所有者,但这会导致我的问题吗?

 rule Participant_CanAccessOwnAssets {
   description: "owner has full access"
   participant(p): "org.example.exampleParticipant"
   operation: ALL
   resource(r): "org.example.assets.exampleAsset"
   condition: (p.getIdentifier() == r.owner.getIdentifier())
   action: ALLOW
 }

标签: hyperledgerhyperledger-composer

解决方案


在我们进入主题之前,关于 ACL 文件只有两条评论:

  1. 在第 13 行,有一个错字(“参与者”)
  2. 在第 5 行,它应该是“org.example.exampleAsset”

至于继承是否是这里的问题,我不确定。但例如在示例网络“信用证”中,我们还看到添加到抽象类的关系。这对您的访问控制规则文件意味着什么是另一回事。

您是否尝试在子类上添加关系以查看是否有效?


推荐阅读