@ghg/passport-gh-portal-strategy
v1.1.6
Published
## Install
Downloads
9
Keywords
Readme
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