local-auth
auth by a local passwd file
Last updated 5 years ago by leonchen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install local-auth 
SYNC missed versions from official npm registry.

local auth middleware for Express

Authentication based on a local .passwd file, for projects that just want to simply prevent public accesses, this shall help you!

Install

npm install local-auth

Usage:

  1. add the following lines to your app.js:
require('local-auth')(app, express, {secret:"<mysecret>", ttl: 86400000})

NOTE that you will need app.use(require("cookie-parser")()) before this line.

  1. create a .passwd file in the same dir of app.js, with the following content (split username and password by spaces):
admin adminpassword
 user userpassword
  1. enjoy!

Options

  1. secret: required, a string used to generate the token.
  2. ttl: optional, the ttl of the token, in ms. default value is 2 days.
  3. dirname: optional, you can specify the root dirname for your custom public/views instead of using the default ones.
  4. byPassPaths: optional, regular expresssion for paths that will be allowed to access for non-logged in clients, like the login path and assets files.

Current Tags

  • 0.0.3                                ...           latest (5 years ago)

1 Versions

  • 0.0.3                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |