Socket
Socket
Sign inDemoInstall

http-auth

Package Overview
Dependencies
5
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.2 to 4.1.0

3

package.json
{
"name": "http-auth",
"description": "Node.js package for HTTP basic and digest access authentication.",
"version": "4.0.2",
"version": "4.1.0",
"author": "Gevorg Harutyunyan (http://github.com/gevorg)",

@@ -39,2 +39,3 @@ "maintainers": [

"mocha": "^7.0.1",
"http-proxy": "^1.18.0",
"request": "^2.88.0"

@@ -41,0 +42,0 @@ },

@@ -22,4 +22,4 @@ # http-auth

// Authentication module.
var auth = require('http-auth');
var basic = auth.basic({
const auth = require('http-auth');
const basic = auth.basic({
realm: "Simon Area.",

@@ -38,4 +38,4 @@ file: __dirname + "/../data/users.htpasswd"

// Authentication module.
var auth = require('http-auth');
var basic = auth.basic({
const auth = require('http-auth');
const basic = auth.basic({
realm: "Simon Area."

@@ -55,2 +55,34 @@ }, (username, password, callback) => {

## [http-proxy](https://github.com/nodejitsu/node-http-proxy/) integration
```javascript
// HTTP proxy module.
const http = require('http'),
httpProxy = require('http-proxy');
// Authentication module.
const auth = require('http-auth');
const basic = auth.basic({
realm: "Simon Area.",
file: __dirname + "/../data/users.htpasswd", // gevorg:gpass, Sarah:testpass
proxy: true
});
// Create your proxy server.
const proxy = httpProxy.createProxyServer({});
http.createServer(basic.check((req, res) => {
proxy.web(req, res, { target: 'http://127.0.0.1:1338' });
})).listen(1337);
// Create your target server.
http.createServer((req, res) => {
res.end("Request successfully proxied!");
}).listen(1338, () => {
// Log URL.
console.log("Server running at http://127.0.0.1:1338/");
});
// You can test proxy authentication using curl.
// $ curl -x 127.0.0.1:1337 127.0.0.1:1337 -U gevorg
```
## Events

@@ -62,4 +94,4 @@

// Authentication module.
var auth = require('http-auth');
var basic = auth.basic({
const auth = require('http-auth');
const basic = auth.basic({
realm: "Simon Area.",

@@ -98,2 +130,3 @@ file: __dirname + "/../data/users.htpasswd"

- `skipUser` - Set this to **true**, if you don't want req.user to be filled with authentication info.
- `proxy` - Set this to **true**, if you want to use it with [http-proxy](https://github.com/http-party/node-http-proxy).

@@ -126,2 +159,9 @@ ## Running tests

## Integrations
- **[http-auth-connect](https://github.com/http-auth/http-auth-connect)** - [Connect](https://github.com/senchalabs/connect) integration.
- **[http-auth-passport](https://github.com/http-auth/http-auth-passport)** - [Passport.js](http://www.passportjs.org/) integration.
- **[http-auth-koa](https://github.com/http-auth/http-auth-koa)** - [Koa framework](http://koajs.com/) integration.
- **[http-auth-hapi](https://github.com/http-auth/http-auth-hapi)** - [Hapi framework](https://hapi.dev/) integration.
## Dependencies

@@ -128,0 +168,0 @@

@@ -31,2 +31,6 @@ "use strict";

if (!options.proxy) {
options.proxy = false;
}
// Assign values.

@@ -73,3 +77,3 @@ this.options = options;

if (this.proxy) {
if (this.options.proxy) {
res.setHeader("Proxy-Authenticate", header);

@@ -118,3 +122,3 @@ res.writeHead(407);

let header = undefined;
if (this.proxy) {
if (this.options.proxy) {
header = req.headers["proxy-authorization"];

@@ -121,0 +125,0 @@ } else {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc