Honey Shah
Honey Shah

Reputation: 421

Use hyperledger composer in production

I have some doubts with how to use hyperledger composer in production. I need to create apis using hyperledger composer which will be used by our front end application which is not of angular js.

  1. I have rest points authenticated with passport-jwt so I need to have one card to access the network. So do I need to pass that card to front end? And how will front end will connect to network with that card to generate more participants and manage whole application?
  2. Where do we need to store cards for created users? In our database or we need to share cards to end user?
  3. How can we create our own custom api using hyperledger composer?

Upvotes: 0

Views: 567

Answers (1)

You need to enable authentication in REST server.

export COMPOSER_CARD=name of your card that will be used to start the REST server
export COMPOSER_AUTHENTICATION=true
export COMPOSER_PROVIDERS='{
 "github":{
 },
 ...
}'

Also you need to switch on REST server Multi-user mode.

export COMPOSER_MULTIUSER=true
export COMPOSER_DATASOURCES='{
  "db":{
     "name":"db",
     "host":"hostname",
     "port":port number,
     "database":"database name",
     "user":"login",
     "password":"password",
     "connector":"mongodb"
  }
}'

and then start the REST server

composer-rest-server

Now the composer REST server will start with the card COMPOSER_CARD with authentication and Multi-user enabled.

If you now visit http://localhost:3000 you will find a new set of APIs "Wallet". Here the wallet functions are defined.

Now the steps for the user will be as follows:

  1. System Admin creates your participant card and issue identity. He sends you the .card file to you.Or your application must have a process to send your card file as email attachment.
  2. He/she authenticates himself with Google or some other provider (what is configured in REST server).
  3. Capture the token returned from that OAuth
  4. Use that Token and call the REST web service /wallet/import to upload his card to be stored in the MongoDB. While uploading make sure that the Card name you input is exactly same as your card name.
  5. Now call any other core application Web Services. REST web service will use your uploaded card details to call the web service.

Hence even if you started the REST server with COMPOSER_CARD it is using your actual card to execute Web services.

Hope this clarifies.

Also you can go through the actual document related to this one for better understanding:

https://hyperledger.github.io/composer/latest/tutorials/google_oauth2_rest

Upvotes: 2

Related Questions