Skip to content

Passport module for authenticating via the 'ember-auth' authentication framework for ember.js

License

Notifications You must be signed in to change notification settings

inerd89/passport-ember-auth

Repository files navigation

Passport-Ember-Auth (Pre-Release)

Ember-Auth authentication strategy for Passport.

This module lets you authenticate HTTP requests in your Node.js applications using auth tokens generated by the Ember-Auth authentication framework for ember.js.

By plugging into Passport, Ember-Auth support can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

Ember-Auth strategy is still being written. It will be published to the NPM Registry at v. 0.1.0. Until then, use the following:

$ npm install git://github.com/inerd89/passport-ember-auth.git

Usage

Configure Strategy

The Ember-Auth authentication strategy authenticates users using an auth token. The strategy requires a verify callback, which accepts that credential and calls done providing a user. Optional info can be passed as well, which will be set by Passport at req.authInfo to be used by later middleware.

passport.use(new EmberAuthStrategy(
  function(token, done) {
    User.findOne({ token: token }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      return done(null, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'EmberAuth' strategy, to authenticate requests. Requests containing auth tokens do not require session support, so the session option can be set to false.

For example, as route middleware in an Express application:

app.get('/profile', 
  passport.authenticate('EmberAuth', { session: false }),
  function(req, res) {
    res.json(req.user);
  });

Issuing Tokens

Issuing auth tokens is up to your server. See the Ember-Auth Docs for what Ember-Auth expects as a valid server response when issuing tokens.

Examples

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

Tests

$ npm install --dev
$ make test

Build Status

Credits

License

The MIT License

Copyright (c) 2013 Austin Maurer <http://austinmaurer.co/>

About

Passport module for authenticating via the 'ember-auth' authentication framework for ember.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published