Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-auth

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-auth - npm Package Compare versions

Comparing version 2.4.10 to 3.0.0

src/auth/base.js

14

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

@@ -17,3 +17,3 @@ "maintainers": [

},
"main": "./gensrc/http-auth.js",
"main": "./src/http-auth.js",
"licenses": [

@@ -35,5 +35,2 @@ {

"devDependencies": {
"babel-cli": "^6.9.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"chai": "^3.5.0",

@@ -43,2 +40,3 @@ "express": "^4.13.4",

"koa": "^1.2.0",
"hapi": "^15.0.3",
"mocha": "^2.5.3",

@@ -49,8 +47,6 @@ "passport": "^0.3.2",

"engines": {
"node": ">=5"
"node": ">=6.7.0"
},
"scripts": {
"test": "mocha --compilers js:babel-core/register --require babel-polyfill",
"compile": "babel src -d gensrc",
"prepublish": "npm run compile"
"test": "mocha"
},

@@ -57,0 +53,0 @@ "keywords": [

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

// Creating new HTTP server.
http.createServer(basic, function(req, res) {
res.end("Welcome to private area - " + req.user + "!");
http.createServer(basic, (req, res) => {
res.end(`Welcome to private area - ${req.user}!`);
}).listen(1337);

@@ -41,3 +41,3 @@

realm: "Simon Area."
}, function (username, password, callback) {
}, (username, password, callback) => {
// Custom authentication

@@ -50,4 +50,4 @@ // Use callback(error) if you want to throw async error.

// Creating new HTTP server.
http.createServer(basic, function(req, res) {
res.end("Welcome to private area - " + req.user + "!");
http.createServer(basic, (req, res) => {
res.end(`Welcome to private area - ${req.user}!`);
}).listen(1337);

@@ -70,4 +70,4 @@ ```

// Setup route.
app.get('/', function(req, res) {
res.send("Hello from express - " + req.user + "!");
app.get('/', (req, res) => {
res.send(`Hello from express - ${req.user}!`);
});

@@ -88,3 +88,3 @@ ```

yield next;
this.body = "Hello from koa - " + this.req.user + "!";
this.body = `Hello from koa - ${this.req.user}!`;
});

@@ -96,3 +96,3 @@

For [koa@next](https://github.com/koajs/koa/tree/v2.x) you can use [http-auth-koa](https://github.com/http-auth/http-auth-koa)
## For [koa@next](https://github.com/koajs/koa/tree/v2.x) you can use [http-auth-koa](https://github.com/http-auth/http-auth-koa)
```javascript

@@ -121,9 +121,6 @@ // Authentication module.

## For [Hapi](http://hapijs.com/) integration you can use [http-auth-hapi](https://github.com/http-auth/http-auth-hapi)
## [Hapi framework](http://hapijs.com/) integration
```javascript
// Import hapi integration.
import authHapi from 'http-auth-hapi'
// Authentication module.
import auth from 'http-auth'
const auth = require('http-auth');

@@ -141,3 +138,3 @@ // Setup auth.

// Register auth plugin.
server.register(authHapi);
server.register(auth.hapi());

@@ -153,3 +150,3 @@ // Setup strategy.

auth: 'http-auth',
handler: function (request, reply) {
handler: (request, reply) => {
reply(`Welcome from Hapi - ${request.auth.credentials.name}!`);

@@ -174,8 +171,8 @@ }

// Setup route.
app.get('/admin', auth.connect(basic), function(req, res) {
res.send("Hello from admin area - " + req.user + "!");
app.get('/admin', auth.connect(basic), (req, res) => {
res.send(`Hello from admin area - ${req.user}!`);
});
// Setup route.
app.get('/', function(req, res) {
app.get('/', (req, res) => {
res.send("Not protected area!");

@@ -203,4 +200,4 @@ });

app.get('/', passport.authenticate('http', {session: false}),
function(req, res) {
res.end("Welcome to private area - " + req.user + "!");
(req, res) => {
res.end(`Welcome to private area - ${req.user}!`);
}

@@ -225,3 +222,3 @@ );

// Create your target server.
http.createServer(function (req, res) {
http.createServer((req, res) => {
res.end("Request successfully proxied!");

@@ -243,12 +240,12 @@ }).listen(1338);

basic.on('success', function(result, req) {
console.log("User authenticated: " + result.user);
basic.on('success', (result, req) => {
console.log(`User authenticated: ${result.user}`);
});
basic.on('fail', function(result, req) {
console.log("User authentication failed: " + result.user);
basic.on('fail', (result, req) => {
console.log(`User authentication failed: ${result.user}`);
});
basic.on('error', function(error, req) {
console.log("Authentication error: " + error.code + " - " + error.message);
basic.on('error', (error, req) => {
console.log(`Authentication error: ${error.code + " - " + error.message}`);
});

@@ -308,3 +305,2 @@ ```

- **[babel](https://babeljs.io/)** - compiler for writing next generation JavaScript.
- **[mocha](https://mochajs.org/)** - simple, flexible, fun javascript test framework for node.js & the browser.

@@ -317,2 +313,3 @@ - **[chai](http://chaijs.com/)** - BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.

- **[koa](http://koajs.com/)** - next generation web framework for node.js.
- **[hapi](http://hapijs.com/)** - A rich framework for building applications and services.

@@ -319,0 +316,0 @@ ## License

Sorry, the diff of this file is not supported yet

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