ibm-watson-data-lab / bluemix-helper-sso

Bluemix Helper for adding support for Single Sign On service to your application
3 stars 1 forks source link

Make the library compatible with passportjs #2

Open kurtdb opened 9 years ago

kurtdb commented 9 years ago

Not exactly a bug, but more of a feature request.

To perform authentication using external platforms on NodeJS, passportjs (http://passportjs.org/) is a very popular library. It provides very easy integrations for different platforms (atm 307 different platforms are supported). Maybe it could be interesting to make this library compatible so people don't have to use yet another library?

An example of how the authentication could be possible through their API:

passport.use(new IBMSSOStrategy({
    callbackURL: "<the url that is to be redirected to>"
  },
  function(token, tokenSecret, profile, done) {
    // asynchronous verification, for effect...
    process.nextTick(function () {
      return done(null, profile);
    });
  }
));

app.get('/auth/ibmsso',
  passport.authenticate('ibm-sso'),
  function(req, res){
    // The request will be redirected to IBM-SSO for authentication, so this
    // function will not be called.
  });
DTAIEB commented 9 years ago

Not sure if you've looked at the code but the implementation is already using passport under the cover. The idea is to make it completely transparent to the user who only needs to pass the express app and the library will set up the passport strategy, OAuth callback, etc.. Perhaps what you're asking is to let the caller access the passport strategy?

kurtdb commented 9 years ago

Personally I would make it work in the same API-way like passport is using right now. Now you are abstracting away all this setup, but downside of this approach is that you are the only one using it. If tomorrow I want to use both your implementation and the passportjs implementation of linkedin, I will have 2 completely different strategies in my code.