Using passport-http on Hyperledger composer REST API

南楼画角 提交于 2019-12-12 08:53:41

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/45734046/using-passport-http-on-hyperledger-composer-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!