Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

basic-auth-middleware

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-auth-middleware

Basic auth middleware

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
208
77.78%
Maintainers
1
Weekly downloads
 
Created
Source

basic-auth-middleware stability

npm version build status downloads js-standard-style

Basic auth middleware

Usage

var Auth = require('basic-auth-middleware')
var http = require('http')

var auth = Auth('my-username', 'some-password')

http.createServer(function (req, res) {
  var ctx = {}
  auth(req, res, ctx, function (err) {
    if (err) return res.end('not authenticated')
    res.end('authentication successful')
  })
})

API

middleware = auth(username, password)

Create a new middleware instance.

middleware(req, res, ctx, done([err]))

Validate an incoming HTTP request. Sets res.statusCode to 401. err is an instance of boom.

License

MIT

Keywords

basic

FAQs

Package last updated on 17 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts