3.0.0 • Published 11 years ago

doorknob v3.0.0

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

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

3.0.0

11 years ago

2.0.2

11 years ago

2.0.1

11 years ago

2.0.0

11 years ago

1.0.0

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago

0.0.1

11 years ago