passport-eipsk-strategy

1.2.0 • Public • Published

passport-eipsk-strategy

Build Status Coverage Status NPM Version

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

Install

$ npm i passport-eipsk-strategy

Usage

Configure Strategy

var passport = require('passport'),
    EipskStrategy = require('passport-eipsk-strategy').Strategy;

passport.use(new EipskStrategy({
    clientID: '<app id>',
    clientSecret: '<secret key>',
    callbackURL: 'http://localhost:3000/auth/eipsk/callback'
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({eipskId: profile.id}, function (err, user) {
      return cb(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

app.get('/auth/eipsk',
  passport.authenticate('eipsk'));

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

License

The MIT License

Package Sidebar

Install

npm i passport-eipsk-strategy

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

4.88 kB

Total Files

6

Last publish

Collaborators

  • fleg