@ghg/passport-gh-portal-strategy
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • 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

Readme

Keywords

none

Package Sidebar

Install

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

Weekly Downloads

1

Version

1.1.6

License

MIT

Unpacked Size

15.8 kB

Total Files

17

Last publish

Collaborators

  • jimghg
  • meh-greenhouse
  • lukevdpalen
  • rickstv
  • iamrobin
  • josvdmanakker
  • kreumkens
  • shanevdb