0

我正在使用 Hyperledger Composer 的在线 Playground ( https://composer-playground.mybluemix.net/ )。

我正在尝试从“pii-network”示例中修改 acl 文件。

只有当参与者想要授权另一个成员而不是他自己时,我才希望获得授权访问......我该怎么做?我对 ACL 文件进行了以下更改,但它没有按预期工作(它授权/撤销任何人,而不是没有自己的任何人):

rule AuthorizeAccessTransaction {
   description: "Allow all participants to submit AuthorizeAccess transactions"
   participant(p): "org.acme.model.Doctor"
   operation: CREATE
   resource(r): "org.acme.model.AuthorizeAccess"
   condition: (r.getIdentifier() != p.getIdentifier())
   action: ALLOW 
}
rule RevokeAccessTransaction {
   description: "Allow all participants to submit RevokeAccess transactions"
   participant(p): "org.acme.model.Doctor"
   operation: CREATE
   resource(r): "org.acme.model.RevokeAccess"
   condition: (r.getIdentifier() != p.getIdentifier())
   action: ALLOW
}
rule OwnRecordFullAccess {
   description: "Allow all participants full access to their own record"
   participant(p): "org.acme.model.Doctor"
   operation: ALL
   resource(r): "org.acme.model.Doctor"
   condition: (r.getIdentifier() === p.getIdentifier())
   action: ALLOW
}
rule ForeignRecordConditionalAccess {
   description: "Allow participants access to other people's records if granted"
   participant(p): "org.acme.model.Doctor"
   operation: ALL
   resource(r): "org.acme.model.Doctor"
   condition: (r.authorized && r.authorized.indexOf(p.getIdentifier()) > -1)
   action: ALLOW
}

rule SystemACL {
   description: "System ACL to permit all access"
   participant: "org.hyperledger.composer.system.Participant"
   operation: ALL
   resource: "org.hyperledger.composer.system.**"
   action: ALLOW

}

我按照https://www.youtube.com/watch?v=VTX-9VyO6OU&feature=youtu.be的指示 更改了 .acl 文件,就像我展示的那样

有谁知道是什么问题?我做错了什么?

我还在这里展示了 cto 文件:

namespace org.acme.model

concept Specialization {
o String hospital
o String hospital_ward //reparto ospedaliero
o String city 
o String county
o String zip
o String field //campo medico di specializzazione

}

participant Doctor identified by username {
o String username
o String firstName
o String lastName
o Specialization specialization 
o DateTime dob optional
o String[] authorized optional

}

abstract transaction DoctorTransaction {
o String username    

}

transaction AuthorizeAccess extends DoctorTransaction {

}

transaction RevokeAccess extends DoctorTransaction {

}

event DoctorEvent {
o DoctorTransaction doctorTransaction

}

4

1 回答 1

0

使用关系作为授权用户的数据类型。

participant Doctor identified by username {
o String username
o String firstName
o String lastName
o Specialization specialization 
o DateTime dob optional
--> Doctor[] authorized optional

然后使用此函数检查 permissions.acl 中的条件

rule ForeignRecordConditionalAccess {
   description: "Allow participants access to other people's records if granted"
   participant(p): "org.acme.model.Doctor"
   operation: ALL
   resource(r): "org.acme.model.Doctor"
   condition: (
    r.authorized.some(function (doc){
      return doc.$identifier === p.$identifier;
    })
   )
   action: ALLOW
}
于 2019-09-24T11:49:02.277 回答