doorknob
add Mozilla Persona user login and LevelDB based session storage to node web apps
Last updated 7 years ago by maxogden .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install doorknob 
SYNC missed versions from official npm registry.

doorknob

convenience module for adding Mozilla Persona user login + LevelDB based session storage to node web apps

Uses levelup for storing sessions and Mozilla Persona (via the persona-id module) for user sign-on.

get it on npm

npm install doorknob

test it out locally

  1. clone this repo
  2. npm install
  3. npm test
  4. open localhost:8080

API

require + make an instance

var doorknob = require('doorknob')(audience || options)

returns a function that you can use to authenticate requests and responses, e.g. function(req, res) {}

arguments:

  • if you just pass a string it has to be the persona audience URL (default is http://localhost:8080)
  • options gets passed to the levelup constructor internally
  • by default valueEncoding is set to json but you can override that
  • you can also pass in your own levelup instance (or technically anything with the same API) via options.db
  • after initializing, doorknob.db is the levelup instance (or the db object you passed in)

handle a request/response

require('http').createServer(function(req, res) {
  doorknob(req, res, function(err, profile) {
    if (profile.loggingIn) // the request has been handled by persona
    if (profile.email) // the user is logged in
    else // the user is not logged in
  })
}).listen(8080)

license

BSD

Current Tags

  • 3.0.0                                ...           latest (7 years ago)

10 Versions

  • 3.0.0                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.3.1                                ...           7 years ago
  • 0.3.0                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |