Miss any of our Open RFC calls?Watch the recordings here! »

@ghg/passport-gh-portal-strategy

1.0.1 • Public • Published

passport-gh-portal-strategy

Install

$ yarn add @ghg/passport-gh-portal-strategy

Usage

Configure Basic Strategy

const {
    BasicStrategy: BasicGHPortalStrategy,
} = require('@ghg/passport-gh-portal-strategy');
 
passport.use(
    new BasicGHPortalStrategy(
        { callbackURL: 'http://localhost:3000/auth/callback' },
        function(accessToken, profile, done) {
            User.findOrCreate({ email: profile.email }, function(err, user) {
                return done(err, user);
            });
        },
    ),
);

Authenticate Requests

Use passport.authenticate(), specifying the 'gh-portal-basic' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/example', passport.authenticate('gh-portal-basic'));
 
app.get(
    '/auth/example/callback',
    passport.authenticate('gh-portal-basic'),
    function(req, res) {
        // Successful authentication, redirect home.
        res.redirect('/');
    },
);

Todo

  • Create strategy for Application Token Strategy

Tests

The test suite is located in the test/ directory. All new features are expected to have corresponding test cases. Ensure that the complete test suite passes by executing:

$ yarn test

Keywords

none

Install

npm i @ghg/passport-gh-portal-strategy

DownloadsWeekly Downloads

50

Version

1.0.1

License

MIT

Unpacked Size

201 kB

Total Files

11

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar