passport-persona

0.2.1 • Public • Published

passport-persona

Build Coverage Quality Dependencies

Passport strategy for authenticating with Mozilla Persona.

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

Persona is a fallback Identity Provider for the BrowserID protocol, a distributed login system from Mozilla. This strategy verifies assertions using Mozilla's Remote Verification API. Applications wishing to verify assertions locally should use passport-browserid.

Install

$ npm install passport-persona

Usage

Configure Strategy

The Persona authentication strategy authenticates users using an assertion of email address ownership, obtained via the navigator.id JavaScript API. The strategy requires a verify callback, which accepts an email address and calls cb providing a user.

passport.use(new PersonaStrategy({
    audience: 'http://www.example.com'
  },
  function(email, cb) {
    User.findByEmail({ email: email }, function (err, user) {
      return cb(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

app.post('/auth/browserid', 
  passport.authenticate('persona', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Examples

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

Contributing

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:

$ make test

Coverage

All new feature development is expected to have test coverage. Patches that increse test coverage are happily accepted. Coverage reports can be viewed by executing:

$ make test-cov
$ make view-cov

Support

Funding

This software is provided to you as open source, free of charge. The time and effort to develop and maintain this project is volunteered by @jaredhanson. If you (or your employer) benefit from this project, please consider a financial contribution. Your contribution helps continue the efforts that produce this and other open source software.

Funds are accepted via PayPal, Venmo, and other methods. Any amount is appreciated.

Credits

License

The MIT License

Copyright (c) 2011-2016 Jared Hanson <http://jaredhanson.net/>

Package Sidebar

Install

npm i passport-persona

Weekly Downloads

3

Version

0.2.1

License

MIT

Last publish

Collaborators

  • jaredhanson