How to use passport-local for authentication on the composer's leisure server

I want to use passport-local to authenticate the user to enter the composer’s leisure server, like other passport strategies (e.g. passport-github , passport-google ).

So, first I try to set the COMPOSER_PROVIDER variable as follows

 "local": { "provider": "local", "module": "passport-local", "usernameField": "username", "passwordField": "password", "authPath": "/auth/local", "successRedirect": "/", "failureRedirect": "/"} 

Then I started the server in docker (with mongo as a constant data source) and added some user to the database collection

The question is: I need to use this passport. Because I run this command and still get a response with 401 Unauthorized

curl -H "Content-Type: application / json" -X POST -d {"Username": "{USER_NAME}", "password": "{user_password}"} " http: // localhost: 3000 / auth / local

Is this passport not enough? Do I need to start another service to authenticate this login locally (e.g. GitHub oAuth app)?

+7
hyperledger-composer
source share
1 answer

I also wanted to do this, but then just edited the server.js file on the composer generation server for basic auth at the end.

  • check where your resident server server is stored

npm root -g

  1. Open where server.js is located
 cd /home/ubuntu/.nvm/versions/node/v8.10.0/lib/node_modules/composer-rest-server/server 
  1. Add this to the code
 const basicauth = require('basicauth-middleware'); app.use(basicauth('username', 'password!'); 
0
source share

All Articles