THIS IS AN EXPERIMENTAL VERSION. PRODUCTION USE IS NOT RECOMMENDED
Passport strategy for authenticating with Dock.io
This module lets you authenticate using Dock.io in your Node.js applications. By plugging into Passport, Dock.io authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
$ npm install passport-dock-io
The Dock.io authentication strategy authenticates users having a Dock.io
account. The strategy requires a verify
callback, which
accepts these credentials and calls done
providing a user, as well as
options
specifying a client_id, prvKey, and client_secret.
passport.use(new DockIOStrategy({
client_id: CLIENT_ID,
prvKey: PRIVATE_KEY,
client_secret: "Something-secret"
},
function(connection_addr, done) {
//check if connection address is associated with a user/webhook notification for new package
//exists if it does then update retrieve the existing user, else confirm the connection using
// docks api then:
// use the ipfs address from the webhook to retrieve the user data using docks api's
}
));
The verify callback can be supplied with the request
object by setting
the passReqToCallback
option to true, and changing callback arguments
accordingly.
passport.use(new DockIOStrategy({
client_id: CLIENT_ID,
prvKey: PRIVATE_KEY,
client_secret: "Something-secret"
},
function(req, profile, done) {
// request object is now first argument
// ...
}
));
Use passport.authenticate()
, specifying the 'dock-io'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/dock-io',
passport.authenticate('dock-io'));
app.get('/auth/dock-io',
passport.authenticate('dock-io', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});