New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

add-basic-auth

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-basic-auth - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

56

index.js

@@ -16,3 +16,3 @@ #!/usr/bin/env node

const unauthorized = res => {
const unauthorized = (res) => {
res.writeHead(401, null, { 'WWW-Authenticate': 'Basic' });

@@ -27,31 +27,35 @@ res.end();

http
.createServer((req, res) => {
const creds = auth(req);
const proxyServer = http.createServer((req, res) => {
const creds = auth(req);
if (!creds) {
return unauthorized(res);
}
if (!creds) {
return unauthorized(res);
}
const { name, pass } = creds;
const { name, pass } = creds;
if (name !== argv.username || pass !== argv.password) {
console.warn(
`Incorrect username and password from ${req.socket.remoteAddress}`
);
return unauthorized(res);
if (name !== argv.username || pass !== argv.password) {
console.warn(
`Incorrect username and password from ${req.socket.remoteAddress}`
);
return unauthorized(res);
}
proxy.web(req, res, null, (error) => {
if (error) {
console.warn(`Upstream error: ${error.message}`);
res.writeHead(502);
res.end();
}
});
});
proxy.web(req, res, null, error => {
if (error) {
console.warn(`Upstream error: ${error.message}`);
res.writeHead(502);
res.end();
}
});
})
.listen(argv.listenPort, () => {
console.log(
`Proxying with basic auth from port ${argv.listenPort} to ${argv.target}`
);
});
proxyServer.on('upgrade', function (req, socket, head) {
proxy.ws(req, socket, head);
});
proxyServer.listen(argv.listenPort, () => {
console.log(
`Proxying with basic auth from port ${argv.listenPort} to ${argv.target}`
);
});
{
"name": "add-basic-auth",
"version": "1.1.2",
"version": "1.1.3",
"description": "Protect a resource with basic auth",

@@ -26,6 +26,6 @@ "bin": {

"dependencies": {
"basic-auth": "2.0.0",
"http-proxy": "1.16.2",
"yargs": "11.0.0"
"basic-auth": "~2.0.1",
"http-proxy": "~1.18.1",
"yargs": "~17.7.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc