Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

bbqsrc/passport-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A turnkey implementation of a local passport.js strategy using MongoDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published