在将条件放在ACL文件中的其他资源上时,如何赋予对特定资源的READ访问权限? [英] How can we give READ access to a particular resource while putting condition on some other resource in ACL file?

查看:57
本文介绍了在将条件放在ACL文件中的其他资源上时,如何赋予对特定资源的READ访问权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是为特定参与者提供读取访问权",而其他参与者的字段却要附加条件,但要以第三个资源为条件.

What I want to do is that give READ ACCESS to a particular participant the fields of other participants but putting condition on third resource.

例如:

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
    }

所以在这里,我想基于一些资产记录将参与者2的个人资料访问权限授予参与者1.

So here I want to give access of profile of participant2 to participant1 based on some asset record.

在作曲家中有可能做到这一点吗?如果没有,其他选择是什么?

Is it possible to this thing in composer and if not what are the other options?

推荐答案

我不认为Hyperledger Composer当前可以做到这一点.您无法在ACL规则中查找不相关的资产.

I do not believe this is currently possible with Hyperledger Composer. You cannot look up an unrelated asset from within an ACL rule.

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

However, you can look up the identifier of a related asset. To make this possible, you would need to add a relationship from the participant to the record as follows:

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字段:

You can then access the related record field from an ACL rule:

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问题来解决与相关资产的关系,这将使您可以查找相关资产的所有字段:

We have a GitHub issue at the moment to resolve the relationships to related assets, which will allow you to look up all fields of a related asset:

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

这篇关于在将条件放在ACL文件中的其他资源上时,如何赋予对特定资源的READ访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆