kerberos17
kerberos17

Reputation: 1

Hyperledger Composer permission.ACL

I want the Seller see just his account: Seller has READ access on his Account. But my rule below don't work. How can I do this?

//Sellers to have read access to Account asset
rule SellerReadAccessAccountsRecord {
description: "Allow seller read access to his Account asset"
participant(p): "org.acme.biznet.Seller"
operation: READ
resource(r): "org.acme.biznet.Account"
condition: (r.owner.getIdentifier() === p.getIdentifier())
action: ALLOW
}

Upvotes: 0

Views: 709

Answers (3)

Alireza Parvizimosaed
Alireza Parvizimosaed

Reputation: 423

Sellers to have read access to Account asset

rule SellerReadAccessAccountsRecord {
description: "Allow seller read access to his Account asset"
participant(p): "org.acme.biznet.Seller"
operation: READ
resource(r): "org.acme.biznet.Seller"
condition: (r.getIdentifier() == p.getIdentifier())
action: ALLOW
}

For more information look at here

Upvotes: 0

kerberos17
kerberos17

Reputation: 1

So that's my solution:

//Seller to have read/write/update access to own air pollution data assets

rule SellerAccessAirPollutionDataRecord {
    description: "Allow sellers read/write/update access to own air pollution data assets"
    participant(p): "org.acme.biznet.Seller"
    operation: CREATE, UPDATE, READ
    resource(r): "org.acme.biznet.AirPollutionData"
    condition: (r.owner.getIdentifier() == p.getIdentifier())
    action: ALLOW
}

//Seller to have read access to sold air pollution data assets

rule SellerReadAccessAirPollutionDataRecord {
    description: "Allow sellers read access to sold air pollution data assets"
    participant(p): "org.acme.biznet.Seller"
    operation: READ
    resource(r): "org.acme.biznet.AirPollutionData"
    condition: (r.owner.getIdentifier() != p.getIdentifier())
    action: ALLOW
}

Upvotes: 0

mohammadjh
mohammadjh

Reputation: 722

If you Account model look like:

asset Account identified by accountId { 
o String accountId 
o String currency default="EUR" 
--> Seller owner
o Double balance default=0.0 
}

Then your current permission will work. Otherwise condition in your permission need to change like following:

condition: (r.ownerId == p.getIdentifier())

Upvotes: 1

Related Questions