0

https://i.imgur.com/nGh5orv.png

I am setting this up in a AWS ec2 environment.Everything works fine till I tried doing a multi-user mode.

I am facing this issue where I had setup the mongoldb persistent data store following the tutorials.

Here is my setup on the envvars.txt

COMPOSER_CARD=admin@property-network
COMPOSER_NAMESPACES=never
COMPOSER_AUTHENTICATION=true
COMPOSER_MULTIUSER=true
COMPOSER_PROVIDERS='{
  "github": {
    "provider": "github",
    "module": "passport-github",
    "clientID": "xxxx",
    "clientSecret": "xxxx
    "authPath": "/auth/github",
    "callbackURL": "/auth/github/callback",
    "successRedirect": "/",
    "failureRedirect": "/"
  }
}'
COMPOSER_DATASOURCES='{
    "db": {
        "name": "db",
        "connector": "mongodb",
        "host": "mongo"   
    }
}'

And I had changed the connection profile of both h1lfv1 and admin@xxx-network to 0.0.0.0 as seen here.

https://github.com/hyperledger/composer/issues/1784

I tried his solution here and it doesn't work. Thank you!

Nico Haase
  • 6,670
  • 34
  • 28
  • 48

1 Answers1

0

Currently there's an issue with admin re-enrolling (strictly an issue with REST server) even though the admin card has a certificate (it ignores it - but fixed in 0.18.x).

Further, there's a hostname resolution issue which you'll need to address because Docker needs to be able to resolve the container names from within the persistent REST server container - we will need to change the hostnames to represent the docker resolvable hostnames as they are current set to localhost values - (example shows a newly issued 'restadmin' card that was created for the purposes of using it to start the REST server and using the standard 'Developer setup' Composer environment):

  1. Create a REST Adninistrator identity restadmin and an associated business network card (used to launch the REST server later).

    composer participant add -c admin@property-network -d '{"$class":"org.hyperledger.composer.system.NetworkAdmin", "participantId":"restadmin"}'

  2. Issue a 'restadmin' identity, mapped to the above participant:

    composer identity issue -c admin@property-network -f restadmin.card -u restadmin -a "resource:org.hyperledger.composer.system.NetworkAdmin#restadmin"

  3. Import and test the card:

    composer card import -f restadmin.card

    composer network ping -c restadmin@property-network

  4. run this one-liner to carry out the resolution changes easily:

    sed -e 's/localhost:/orderer.example.com:/' -e 's/localhost:/peer0.org1.example.com:/' -e 's/localhost:/peer0.org1.example.com:/' -e 's/localhost:/ca.org1.example.com:/' < $HOME/.composer/cards/restadmin@property-network/connection.json > /tmp/connection.json && cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@property-network

  5. Try running the REST server with the card -c restadmin@property-network - if you're running this tutorial https://hyperledger.github.io/composer/latest/integrating/deploying-the-rest-server then you will need to put this CARD NAME in the top of your envvars.txt and then ensure you run source envvars.txt to get it set 'in your current shell environment'

  6. If you wish to issue further identities - say kcoe below - from the REST client (given you're currently 'restadmin') you simply do the following (first two can be done in Playground too FYI):

    composer participant add -c admin@trade-network -d '{"$class":"org.acme.trading.Trader","tradeId":"trader2", "firstName":"Ken","lastName":"Coe"}'

    composer identity issue -c admin@trade-network -f kcoe.card -u kcoe -a "resource:org.acme.trading.Trader#trader2"

    composer card import -f kcoe.card # imported to the card store

Next - one-liner to get docker hostname resolution right, from inside the persistent dockerized REST server:

sed -e 's/localhost:/orderer.example.com:/' -e 's/localhost:/peer0.org1.example.com:/' -e 's/localhost:/peer0.org1.example.com:/' -e 's/localhost:/ca.org1.example.com:/' < $HOME/.composer/cards/kcoe@trade-network/connection.json > /tmp/connection.json && cp -p /tmp/connection.json $HOME/.composer/cards/kcoe@trade-network
  1. Start your REST server as per the Deploy REST server doc:

docker run \ -d \ -e COMPOSER_CARD=${COMPOSER_CARD} \ -e COMPOSER_NAMESPACES=${COMPOSER_NAMESPACES} \ -e COMPOSER_AUTHENTICATION=${COMPOSER_AUTHENTICATION} \ -e COMPOSER_MULTIUSER=${COMPOSER_MULTIUSER} \ -e COMPOSER_PROVIDERS="${COMPOSER_PROVIDERS}" \ -e COMPOSER_DATASOURCES="${COMPOSER_DATASOURCES}" \ -v ~/.composer:/home/composer/.composer \ --name rest \ --network composer_default \ -p 3000:3000 \ myorg/my-composer-rest-server

  1. From the System REST API in http://localhost:3000/explorer - go to the POST /wallet/import operation and import the card file kcoe.card with (in this case) the card name set to kcoe@trade-network and click on 'Try it Out' to import it - it should return a successful (204) response.

  2. This is set as the default ID in the Wallet via System REST API endpoint

(if you need to set any further imported cards as the default card name in our REST client Wallet - go to the POST /wallet/name/setDefault/ method and choose the card name and click on Try it Out. This would now the default card).

  1. Test it out - try getting a list of Traders (trade-network example):

Return to the Trader methods in the REST API client and expand the /GET Trader endpoint then click 'Try it Out' . It should confirm that we are now using a card in the business network, and should be able to interact with the REST Server and get a list of Traders (that were added to your business network)..

Paul O'Mahony
  • 6,680
  • 1
  • 7
  • 15