如何在Hyperledger Fabric的NODE-SDK中设置Permission功能?

问题描述 投票:0回答:2

在ChainCode开发中,何时在网络中拥有多个组织,以防只有特定的组织才能调用特定的链代码功能。

是否可以在超级边缘Fabric的Node-SDK中使用?如果可能那么如何在开发中实施?

hyperledger-fabric hyperledger blockchain hyperledger-fabric-sdk-js
2个回答
1
投票

只需使用stub.getCreator()并探索返回的对象。

let sender = await stub.getCreator();
let senderOrg = sender.mspid;
if(senderOrg=='SpecialOrg'){
    // do your business
} else {
    // whatever
}

更多信息直接在interfaces.gohttps://github.com/hyperledger/fabric/blob/release-1.4/core/chaincode/shim/interfaces.go


1
投票

(身份)基于属性的访问控制(ABAC)可以写入智能合约而不是NodeSDK客户端应用程序。

使用Fabric 1.4和新的编程模型,Client Identity对象包含在Context对象中,您可以检查属性并根据这些属性编写访问控制逻辑。

这是doc for the client identity object

Fabric CA文档中有一个short section about ABAC

(ABAC要求您在注册用户时向其添加属性!)

您可以考虑使用beforeTransaction()作为实现访问控制的地方。

这个could be implemented in a typescript example有一个“壳”。

© www.soinside.com 2019 - 2024. All rights reserved.