Comparing version 0.0.3 to 1.0.0
@@ -0,16 +1,10 @@ | ||
var parser = require('./parser'); | ||
/** | ||
* HTTP Basic Auth for Node.js | ||
* HTTP Basic Auth middleware provider. | ||
* | ||
* @package basic | ||
* @author Andrew Sliwinski <andrew@diy.org> | ||
* @param {function} handler Function used to evaluate username & password | ||
* | ||
* @return {function} | ||
*/ | ||
/** | ||
* Dependencies | ||
*/ | ||
var basic = require('./basic'); | ||
/** | ||
* Export | ||
*/ | ||
module.exports = function (handler) { | ||
@@ -28,10 +22,10 @@ // Default handler method | ||
if (!header) { | ||
var denied = new Error('access denied') | ||
denied.status = denied.statusCode = 401 | ||
var denied = new Error('access denied'); | ||
denied.status = denied.statusCode = 401; | ||
return callback(denied); | ||
} | ||
var auth = basic(header); | ||
var auth = parser(header); | ||
handler(auth.username, auth.password, callback); | ||
}; | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "HTTP Basic Auth for Node.js", | ||
"version": "0.0.3", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/thisandagain/basic", | ||
@@ -19,5 +19,4 @@ "license": "MIT", | ||
"devDependencies": { | ||
"codebux": "~0.1.2", | ||
"jshint-tap-simple": "~1.0.2", | ||
"tap": "~0.3.1" | ||
"eslint": "1.10.3", | ||
"tap": "2.3.3" | ||
}, | ||
@@ -24,0 +23,0 @@ "optionalDependencies": {}, |
@@ -11,6 +11,6 @@ ## basic | ||
```javascript | ||
var basic = require('basic'), | ||
http = require('http'); | ||
var http = require('http'); | ||
var basic = require('../../lib/index'); | ||
var auth = basic(function (user, pass, callback) { | ||
var auth = basic(function (user, pass, callback) { | ||
if (user === 'let' && pass === 'me in') return callback(null); | ||
@@ -17,0 +17,0 @@ callback(401); |
@@ -1,6 +0,5 @@ | ||
var basic = require('../../lib/index'), | ||
http = require('http'); | ||
var http = require('http'); | ||
var basic = require('../../lib/index'); | ||
var auth = basic(function (user, pass, callback) { | ||
var auth = basic(function (user, pass, callback) { | ||
if (user === 'let' && pass === 'me in') return callback(null); | ||
@@ -12,5 +11,8 @@ callback(401); | ||
auth(req, res, function (err) { | ||
res.writeHead(err || 200); | ||
var head = {}; | ||
if (err) head = {'WWW-Authenticate': 'Basic realm="Secure Area"'}; | ||
res.writeHead(err || 200, head); | ||
res.end(); | ||
}); | ||
}).listen(8000); | ||
}).listen(8000); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7179
2
14
134
0