Search code examples
hyperledger-fabrichyperledger-fabric-ca

How to make a user authentication using hyperledger fabric


i have a current channel of hyperledger fabric with chaincode that does CRUD operations my question is that is there any way to make a method in a chaincode that registers the new user when certain condition match.


Solution

  • You can use one of several methods to get the identity of the user:

    • GetCreator
    • GetId
    • GetMSPId

    They are part of the Client Identity Chaincode Library, documented here: https://pkg.go.dev/github.com/hyperledger/fabric-chaincode-go/pkg/cid#section-readme

    The Hyperledger Fabric docs provide some help for access control also if you're interested in that: https://hyperledger-fabric.readthedocs.io/en/latest/private-data/private-data.html?highlight=getmspid#private-data-sharing-patterns