在ChainCode开发中,何时在网络中拥有多个组织,以防只有特定的组织才能调用特定的链代码功能。
是否可以在超级边缘Fabric的Node-SDK中使用?如果可能那么如何在开发中实施?
只需使用stub.getCreator()
并探索返回的对象。
let sender = await stub.getCreator();
let senderOrg = sender.mspid;
if(senderOrg=='SpecialOrg'){
// do your business
} else {
// whatever
}
更多信息直接在interfaces.go
:https://github.com/hyperledger/fabric/blob/release-1.4/core/chaincode/shim/interfaces.go
(身份)基于属性的访问控制(ABAC)可以写入智能合约而不是NodeSDK客户端应用程序。
使用Fabric 1.4和新的编程模型,Client Identity对象包含在Context对象中,您可以检查属性并根据这些属性编写访问控制逻辑。
这是doc for the client identity object。
Fabric CA文档中有一个short section about ABAC。
(ABAC要求您在注册用户时向其添加属性!)
您可以考虑使用beforeTransaction()作为实现访问控制的地方。