Skip to content

cantina/cantina-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

11cdda2 · Oct 25, 2017

History

30 Commits
May 23, 2012
Aug 3, 2014
Aug 3, 2014
Jul 29, 2014
Oct 25, 2017

Repository files navigation

cantina-auth

Wraps passport to provde authentication for your cantina application.

Dependencies

Provides

  • app.passport - An initialized passport instance.

Adds Middleware

  • extendRequest() - Adds: req.logIn, req.logOut, req.isAuthenticated, req.isUnauthenticated, res.redirect(location, status)
  • passport.initialize()
  • passport.session()
  • GET '/logout' - Route handler to log a user out.

Configuration

  • logoutPath: The path that should log a user out.
  • logoutRedirect: The path a logged-out user should be redirected to.

Defaults

{
  logoutPath: '/logout',
  logoutRedirect: '/'
}

Usage

Your application MUST provide handlers for serializing and deserializing users.

  • app.serializeUser (user) - Returns a user's id.
  • auth:deserialize (id, cb) - Should load user and call cb with (err, user)

Example

var app = require('cantina').createApp();

app.boot(function (err) {
  if (err) throw err;

  app.serializeUser = function (user) {
    return user.id;
  };
  app.deserializeUser = function(id, done) {
    loadUser(id, function(err, user) {
      done(err, user);
    });
  };

  app.require('cantina-web');
  app.require('cantina-auth');

  app.start();
});

Developed by Terra Eclipse

Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.

About

Stores and validates user credentials hashes

Resources

License

Stars

Watchers

Forks

Packages

No packages published