Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using passport-http on Hyperledger composer REST API

I would like to know if it is possible to use passport-http to secure the REST API of Hyperledger Composer generated with the composer-rest-server and what would be the export COMPOSER_PROVIDERS='{}' configuration.

The idea is to use the identities previously generated and assigned to participants with the composer to authenticate the GET and POST requests on the API.

If it were possible, how would the userID and userSecret be passed, as a special http header, in the body or as a simple basic auth header?

like image 560
arkandas Avatar asked Nov 07 '22 18:11

arkandas


1 Answers

I've not tried, but it should be able to. The Composer REST server uses the open source Passport authentication middleware, its a matter of configuration. Multiple Passport strategies can be selected, allowing clients of the REST server to select a preferred authentication mechanism.

The strategy for passport-http is here -> https://github.com/jaredhanson/passport-http

You can try something like:


  export COMPOSER_PROVIDERS='{
  "basic": {
    "provider": "basic",
    "module": "passport-http",
    "clientID": "REPLACE_WITH_CLIENT_ID",
    "clientSecret": "REPLACE_WITH_CLIENT_SECRET",
    "authPath": "/auth/local",
    "callbackURL": "/auth/local/callback",
    "successRedirect": "/",
    "failureRedirect": "/login" 
     }
    }'

I assume you know how to configure your passport-http strategy. and check out RESTful Node.js Application with passport-http - and see an example (right near the end) of an app consuming REST Endpoints right near the end.

like image 93
Paul O'Mahony Avatar answered Nov 15 '22 06:11

Paul O'Mahony