jaredhanson / passport-browserid

BrowserID authentication strategy for Passport and Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

passport-browserid

Build Coverage Quality Dependencies

Passport strategy for authenticating with BrowserID.

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

BrowserID is an open, decentralized protocol for authenticating users based on email addresses, developed by Mozilla. It is commonly associated with Persona, the brand used for Mozilla's implementation of BrowserID. This strategy performs local verification of assertions, delivering on BrowserID's promise of ensuring user privacy.

Install

$ npm install passport-browserid

Usage

Configure Strategy

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

passport.use(new BrowserIDStrategy({
    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 'browserid' strategy, to authenticate requests.

For example, as route middleware in an Express application:

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

Considerations

Specification

This module is implemented based on the specifications being developed by Mozilla Identity, which remain a work-in-progress and are not final. Implementers are encouraged to track the progress of these specifications and update update their implementations as necessary. Furthermore, the implications of relying on non-final specifications should be understood prior to deployment.

While the specifications remain under development, it is recommended to use Mozilla's Remote Verification API. This functionality is implemented by passport-persona.

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-2017 Jared Hanson <http://jaredhanson.net/>

Sponsor

About

BrowserID authentication strategy for Passport and Node.js.

License:MIT License


Languages

Language:JavaScript 99.2%Language:Makefile 0.8%