
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@hotelquickly/basic-auth
Advanced tools
Generic basic auth Authorization header field parser for whatever.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install command:
$ npm install basic-auth
var auth = require('basic-auth')
Get the basic auth credentials from the given request. The Authorization
header is parsed and if the header is invalid, undefined is returned,
otherwise an object with name and pass properties.
Parse a basic auth authorization header string. This will return an object
with name and pass properties, or undefined if the string is invalid.
Reads from env variable BASIC_AUTH in format user:pass to treat as valid
then get credentials using auth and validates against set in env.
In case of mismatch through error instance of ErrorClass
Pass a node request or koa Context object to the module exported. If
parsing fails undefined is returned, otherwise an object with
.name and .pass.
var auth = require('basic-auth')
var user = auth(req)
// => { name: 'something', pass: 'whatever' }
A header string from any other location can also be parsed with
auth.parse, for example a Proxy-Authorization header:
var auth = require('basic-auth')
var user = auth.parse(req.getHeader('Proxy-Authorization'))
var http = require('http')
var auth = require('basic-auth')
// Create server
var server = http.createServer(function (req, res) {
var credentials = auth(req)
if (!credentials || credentials.name !== 'john' || credentials.pass !== 'secret') {
res.statusCode = 401
res.setHeader('WWW-Authenticate', 'Basic realm="example"')
res.end('Access denied')
} else {
res.end('Access granted')
}
})
// Listen
server.listen(3000)
FAQs
node.js basic auth parser
We found that @hotelquickly/basic-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.