我们如何在 ACL 文件中对其他资源施加条件的同时授予对特定资源的 READ 访问权限



我想做的是向特定参与者提供其他参与者的字段的读取访问权限,但对第三个资源设置条件。

例如:

rule SampleRule{
       description: "Allow the Participant1 to view Participant2 profile"
       participant(m): "org.sample.blockchain.Participant1"
       operation: READ
       resource(v): "org.sample.blockchain.Participant2"
       condition:(
                  v.getIdentifier() == Record.Participant1.getIdentifier() 
                     && m.getIdentifier() == Record.Participant2.getIdentifier()
                )
       action: ALLOW
    }
    asset Record identified by Id {
       o String Id
       --> Participant1 Participant1
       --> Participant2 Participant2
    }
    participant Participant1 identified by EmailId{
       o String EmailId
       o String Name
       o Integer Age
    }
    participant Participant2 identified by EmailId{
       o String EmailId
       o String Name
       o Integer Age
    }

所以在这里,我想根据一些资产记录向参与者 1 提供参与者 2 个人资料的访问权限。

曲家有没有可能这样做,如果不是,还有什么其他选择?

我不相信这目前在Hyperledger Composer上是可能的。您无法从 ACL 规则中查找不相关的资产。

但是,您可以查找相关资产的标识符。为此,您需要将参与者的关系添加到记录中,如下所示:

asset Record identified by Id {
    o String Id
    --> Participant1 Participant1
    --> Participant2 Participant2
}
participant Participant1 identified by EmailId{
    o String EmailId
    o String Name
    o Integer Age
    --> Record record // note the new record field
}

然后,您可以从 ACL 规则访问相关的record字段:

rule SampleRule {
    description: "Allow the Participant1 to view Participant2 profile"
    participant(m): "org.sample.blockchain.Participant1"
    operation: READ
    resource(v): "org.sample.blockchain.Participant2"
    condition: (
        m.record.getIdentifier() === v.record.getIdentifier()
    )
    action: ALLOW
}

我们目前有一个 GitHub 问题来解决与相关资产的关系,这将允许您查找相关资产的所有字段:

https://github.com/hyperledger/composer/issues/1007

最新更新