Search code examples
authenticationidentityhyperledger-composermulti-userwallet

hyperledger-composer: "The current identity, with the name 'admin' and the identifier 'xxx' has not been registered"


My question is on Authentication in Hyperledger Composer.

I created a business network (and on top of that also an angular app but that angular app is not relevant to this question).

I started the rest server with authentication and multi-user mode enabled.

Going to the rest server at localhost:3000, requests were blocked due to missing authentication - as expected.

Before starting the rest server I had run the following command:

export COMPOSER_PROVIDERS='{
  "github": {
    "provider": "github",
    "module": "passport-github",
    "clientID": "<MY CLIENT ID>",
    "clientSecret": "MY CLIENT SECRET",
    "authPath": "/auth/github",
    "callbackURL": "/auth/github/callback",
    "successRedirect": "http://localhost:4200",
    "failureRedirect": "/"
  }
}'

That is, authentication requires GitHub-login. So I went to http://localhost:3000/auth/github and logged into GitHub.

Then I went back to http://localhost:3000/explorer and tried to send a request. I got the following error: "A business network card has not been specified".

enter image description here

I thought this meant that I needed to import the business network card of the current user. The current user was, in this case, the NetworkAdmin that was created automatically when I started the business network using the following command:

composer network start --networkName composer-app --networkVersion 0.0.1 --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw

So I imported the business network card of this NetworkAdmin by selecting the respective file and sending the relevant HTTP request (see screenshot):

enter image description here

After confirming that the card had been imported successfully, I then tried to send a request again.

This time I got the following error message:

"Error trying to ping. Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: The current identity, with the name 'admin' and the identifier '57e1bd6da04f49b1703d4813d4950c4c5cd6641fce3f805fae2545023fb2f16b', has not been registered"

So I guess I am doing something wrong/misunderstanding something.

Does anybody know what I am doing wrong?

enter image description here


Solution

  • This looks like a problem with the Network Admin card you have imported. When the Identity is Issued (and the Card is created) a one-time secret is created. When the card is used for the first time the secret is exchanged for Certificates/Keys and the the one-time secret is invalidated.

    I'm guessing that you have imported the .card file which you have then used to start the REST server - so now the secret is invalid. If I'm right, you need to export the card on the Command line with composer card export -c admin@<my-network> -f admin-plus-cert.card and import that new .card file into the REST server wallet.

    Once you have that card successfully imported, you can go ahead and access the Business Network, and also issue new identities (with new cards, and import those into the REST server too)