Isha Padalia
Isha Padalia

Reputation: 1222

How can put a Permission on function in NODE-SDK of Hyperledger Fabric?

In ChainCode development, When to have a Multiple organization in the network, In case only a specific Organisation can call a specific function of chain code.

Is it possible in Node-SDK of hyperledger Fabric? if possible then How can implement in development?

Upvotes: 0

Views: 376

Answers (2)

R Thatcher
R Thatcher

Reputation: 5570

(Identity) Attribute Based Access Control (ABAC) can be written into the Smart Contract rather than the NodeSDK client app.

With Fabric 1.4 and the new programming model, the Client Identity object is included in the Context object and you can examine the attributes and write your access control logic based on these.

This is the doc for the client identity object.

And there is a short section about ABAC in the Fabric CA docs.

(ABAC requires that you add attributes to the users when they are registered! )

You could consider using the beforeTransaction() as a place to implement your access control.

There is a "shell" of how this could be implemented in a typescript example.

Upvotes: 1

jfc
jfc

Reputation: 190

Just use stub.getCreator() and explore the returned object.

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

More information directly in interfaces.go: https://github.com/hyperledger/fabric/blob/release-1.4/core/chaincode/shim/interfaces.go

Upvotes: 1

Related Questions