Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
koa-basic-auth
Advanced tools
Readme
Add simple "blanket" basic auth with username / password. If you require anything more specific just use the basic-auth module.
v4.x+ Breaking Change: This package no longer requires both a username and a password. Either or is supported, see #39 for more insight.
$ npm install koa-basic-auth
Password protect downstream middleware:
const auth = require('koa-basic-auth');
const Koa = require('koa');
const app = new Koa();
// custom 401 handling
app.use(async (ctx, next) => {
try {
await next();
} catch (err) {
if (401 == err.status) {
ctx.status = 401;
ctx.set('WWW-Authenticate', 'Basic');
ctx.body = 'cant haz that';
} else {
throw err;
}
}
});
// require auth
app.use(auth({ name: 'tj', pass: 'tobi' }));
// secret response
app.use(async (ctx) => {
ctx.body = 'secret';
});
app.listen(3000, function () {
console.log('listening on port 3000');
});
Example request:
$ curl -H "Authorization: basic dGo6dG9iaQ==" http://localhost:3000/ -i
HTTP/1.1 200 OK
X-Powered-By: koa
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Date: Sat, 30 Nov 2013 19:35:17 GMT
Connection: keep-alive
secret
Using the mount middleware you may specify auth for a given prefix:
const mount = require('koa-mount');
const auth = require('koa-basic-auth');
app.use(mount('/admin', auth({ name: 'tobi', pass: 'ferret' })));
MIT
FAQs
Blanket basic auth middleware for koa
The npm package koa-basic-auth receives a total of 19,690 weekly downloads. As such, koa-basic-auth popularity was classified as popular.
We found that koa-basic-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.