【问题标题】:pii-network - acl permission- authorize/revoke access network but not to himselfpii-network - acl 权限 - 授权/撤销访问网络,但不是对他自己
【发布时间】:2017-09-06 11:26:25
【问题描述】:

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

我正在尝试从“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

}

【问题讨论】:

  • 只是一些反馈。发布所有 ACL,而不仅仅是相关部分,可能会使可能提供帮助的人感到困惑。此外,您也可以发布您的 cto 文件以获取更多信息(尤其是因为您已经更改了它)。
  • 你说过这不能“按预期”工作。如果你能描述你所期望的和你实际经历的,那将会有所帮助。 ACL 的哪一部分不起作用? ...是的,请同时发布您的 cto 文件的相关部分。

标签: acl hyperledger hyperledger-composer access-rules


【解决方案1】:

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

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
}

【讨论】:

    最近更新 更多