node package manager

passport-slidefuse

Passport-Slidefuse

Passport strategy for authenticating with Slidefuse using the OAuth 2.0 API.

Install

$ npm install passport-slidefuse

Usage

Configure Strategy

The Slidefuse authentication strategy authenticates users using a Slidefuse account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a client ID, client secret, and callback URL.

passport.use(new SlidefuseStrategy({
    clientID: SF_CLIENT_ID,
    clientSecret: SF_CLIENT_SECRET,
    callbackURL: "http://localhost:3000/login/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ sfId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'slidefuse' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/login',
  passport.authenticate('slidefuse'));

app.get('/login/callback', 
  passport.authenticate('slidefuse', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Credits