2017-08-09 53 views
0

請問我們知道ACL是否在操場上工作?ACL在操場上工作?

我想創建一個規則,資產的所有者只能修改規則。我在遊樂場嘗試,這是行不通的

我創建文件作爲資產和供應商作爲資產的所有者。然後,創建名爲file1的資產將supplier1作爲所有者。當我執行提交交易時,供應商2也可以修改交易。我的規則是無效的嗎?我需要一些更加不可思議的嗎?

 /** 
    * New model file 
    */ 

    namespace org.acme.model 

    enum TransactionState { 
     o CREATED 
     o VERIFIED 
    } 

    asset File identified by fileId { 
     o String fileId 
     o String data 
     --> Supplier owner 
     o TransactionState state 
    } 

    participant Supplier identified by supplierId { 
     o String supplierId 
     o String emailId 
     o String details 
    } 



    transaction DataValidate { 
     --> File asset 
     o TransactionState state 
     --> Supplier supplier 
    } 

/** 
* Data Validation by Supplier 
* @param {org.acme.model.DataValidate} dataValidate - the DataValidate transaction 
* @transaction 
*/ 
function DataValidate(dataValidate) { 
    dataValidate.asset.state = dataValidate.state; 
    return getAssetRegistry('org.acme.model.File') 
     .then(function (assetRegistry) { 
      return assetRegistry.update(dataValidate.asset); 
     }); 
} 


rule Rule1 { 
    description: "can perform ALL operations , IF the participant is owner of the asset" 
    participant(m): "org.acme.model.Supplier" 
    operation: ALL 
    resource(v): "org.acme.model.File" 
    condition: (v.owner.getIdentifier() == m.getIdentifier()) 
    action: ALLOW 
} 


rule Member { 
    description: "Allow the member read access" 
    participant: "org.acme.model.Supplier" 
    operation: READ 
    resource: "org.acme.model.*" 
    action: ALLOW 
} 

我的標準,數據驗證應該只由文件的所有者,而不是其他人。如何處理它

回答

2

要回答你的主要問題 - 是的ACL文件確實在在線遊樂場工作,我讓它爲我的應用程序之一工作。如果您不是指網絡遊樂場,我不確定我的答案的其餘部分是否有幫助。

如果您正在使用在線Playground,假設您已經到了右上角說'管理員'並創建新身份並將其發佈給參與者?如果沒有,你可以這樣做:

  1. 點擊「管理」在操場的右上方

  2. 「+發行新ID」

  3. 提供用戶ID(不管你喜歡)和參與者(將是您之前創建的),然後按'創建新'

  4. 選擇選項2:'+添加到我的電子錢包'(這將允許您使用該標識,您將成爲'參與者

我問的原因是,即使你的ACL文件工作,如果你仍然是'管理員'的身份,你仍然可以查看/做你想做的一切。

另一件事,你可以在Rule1中嘗試'==='而不是'=='嗎?這兩條規則是有道理的,從所有用戶都可以查看,但是如果除所有者之外的任何人嘗試驗證該資產,則會出現錯誤,因爲它需要未授予的UPDATE權限。

希望這會有所幫助。