Skip to content

homebrewing/passport-maltio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passport-Maltio

Passport strategies for authenticating with Malt.io using OAuth 2.0.

This module lets you authenticate using Malt.io in your Node.js applications. By plugging into Passport, Malt.io authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-maltio

Usage

Configure Strategy

The Malt.io OAuth 2.0 authentication strategy authenticates users using a Malt.io 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.

var MaltioStrategy = require('passport-maltio');

passport.use(new MaltioStrategy({
    clientID: MALTIO_CLIENT_ID,
    clientSecret: MALTIO_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/maltio/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ externalId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'maltio' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/maltio',
  passport.authenticate('maltio'));

app.get('/auth/maltio/callback', 
  passport.authenticate('maltio', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Now, to log in a user

Examples

For a complete, working example, refer to the example directory.

Credits

License

The MIT License

Copyright (c) 2013 Daniel G. Taylor

About

Malt.io authentication module for Passport.js using OAuth2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published