passport-bong
v0.1.7
Published
Bong authentication strategy for Passport.
Downloads
2
Maintainers
Readme
Passport-Bong
Copied from Passport-github by Jared Hanson
Passport strategy for authenticating with Bong using the OAuth 2.0 API.
This module lets you authenticate using Bong in your Node.js applications. By plugging into Passport, Bong authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install passport-bong
Usage
Configure Strategy
The Bong authentication strategy authenticates users using a Bong 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 BongStrategy({
clientID: BONG_CLIENT_ID,
clientSecret: BONG_CLIENT_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/bong/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ bongId: profile.uid }, function (err, user) {
return done(err, user);
});
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'Bong'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/bong',
passport.authenticate('bong'));
app.get('/auth/bong/callback',
passport.authenticate('bong', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
Examples
For a complete, working example, refer to the login example.
$ git clone https://github.com/junmer/passport-bong
$ cd passport-bong/examples/login && npm install
$ vi app.js //update BONG_CLIENT_ID, BONG_CLIENT_SECRET
$ node app.js
Tests
$ npm install --dev
$ make test
Credits
License
Copyright (c) 2011-2013 Jared Hanson <http://jaredhanson.net/>