Skip to content

SpringRole/passport-dock-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THIS IS AN EXPERIMENTAL VERSION. PRODUCTION USE IS NOT RECOMMENDED

passport-dock-io

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.

Install

$ npm install passport-dock-io

Usage

Configure Strategy

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 
  }
));

Parameters

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
    // ...
  }
));

Authenticate Requests

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('/');
  });

Credits

License

The MIT License

About

A PassportJs strategy for Dock.io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published