passport-mongodb

1.2.0 • Public • Published

passport-mongodb

MongoDB (using mongoose) support for Passport. Turnkey magic!

Installation

$ npm install passport-mongodb

Usage

Simplest setup:

var passport = require('passport'),
    passportMongo = require('passport-mongodb'),
    mongoose = require('mongoose'),
    app = require('koa')(),
    router = require('koa-router')();
 
// Connect via mongoose
mongoose.connect(...);
 
/* Some time passes—punch is served, life is generally merry. */
 
passportMongo.setup(passport);
 
/* Usual passport config and app stuff goes here. */
 
router.get('/test', passport.authenticate('mongodb'), function* () {
  return this.body = "Amazing, " + this.user.displayName + "!" ;
});

The setup method provides sane defaults for serialisation and deserialisation of the User object, and adds the Strategy with defaults to the passport instance.

passportMongo also has exported the User model and Strategy class for your interactions and customisation as necessary.

License

ISC

Readme

Keywords

none

Package Sidebar

Install

npm i passport-mongodb

Weekly Downloads

3

Version

1.2.0

License

ISC

Last publish

Collaborators

  • bbqsrc