http-auth
Advanced tools
Comparing version 2.4.5 to 2.4.6
@@ -11,6 +11,10 @@ "use strict"; | ||
var _fs = require("fs"); | ||
var _fs = require('fs'); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _events = require('events'); | ||
var _events2 = _interopRequireDefault(_events); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,4 +24,13 @@ | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
// Event module. | ||
// Base authentication. | ||
var Base = function () { | ||
var Base = function (_events$EventEmitter) { | ||
_inherits(Base, _events$EventEmitter); | ||
// Constructor. | ||
@@ -27,2 +40,4 @@ function Base(options, checker) { | ||
var _this = _possibleConstructorReturn(this, (Base.__proto__ || Object.getPrototypeOf(Base)).call(this)); | ||
if (!options.msg401) { | ||
@@ -45,11 +60,12 @@ options.msg401 = "401 Unauthorized"; | ||
// Assign values. | ||
this.options = options; | ||
this.checker = checker; | ||
_this.options = options; | ||
_this.checker = checker; | ||
// Loading users from file, if file is set. | ||
this.options.users = []; | ||
_this.options.users = []; | ||
if (!checker && options.file) { | ||
this.loadUsers(); | ||
_this.loadUsers(); | ||
} | ||
return _this; | ||
} | ||
@@ -61,3 +77,3 @@ | ||
_createClass(Base, [{ | ||
key: "processLine", | ||
key: 'processLine', | ||
value: function processLine(userLine) { | ||
@@ -70,3 +86,3 @@ throw new Error('Not defined!'); | ||
}, { | ||
key: "parseAuthorization", | ||
key: 'parseAuthorization', | ||
value: function parseAuthorization(header) { | ||
@@ -79,3 +95,3 @@ throw new Error('Not defined!'); | ||
}, { | ||
key: "findUser", | ||
key: 'findUser', | ||
value: function findUser(req, clientOptions, callback) { | ||
@@ -88,3 +104,3 @@ throw new Error('Not defined!'); | ||
}, { | ||
key: "generateHeader", | ||
key: 'generateHeader', | ||
value: function generateHeader(result) { | ||
@@ -97,3 +113,3 @@ throw new Error('Not defined!'); | ||
}, { | ||
key: "ask", | ||
key: 'ask', | ||
value: function ask(res, result) { | ||
@@ -117,3 +133,3 @@ var header = this.generateHeader(result); | ||
}, { | ||
key: "check", | ||
key: 'check', | ||
value: function check(req, res, callback) { | ||
@@ -127,4 +143,7 @@ var self = this; | ||
} else if (!result.user) { | ||
self.emit('fail'); | ||
self.ask(res, result); | ||
} else { | ||
self.emit('success', result); | ||
if (!this.options.skipUser) { | ||
@@ -144,3 +163,3 @@ req.user = result.user; | ||
}, { | ||
key: "isAuthenticated", | ||
key: 'isAuthenticated', | ||
value: function isAuthenticated(req, callback) { | ||
@@ -178,5 +197,5 @@ var self = this; | ||
}, { | ||
key: "loadUsers", | ||
key: 'loadUsers', | ||
value: function loadUsers() { | ||
var _this = this; | ||
var _this2 = this; | ||
@@ -187,3 +206,3 @@ var users = _fs2.default.readFileSync(this.options.file, 'UTF-8').replace(/\r\n/g, "\n").split("\n"); | ||
users.forEach(function (u) { | ||
_this.processLine(u); | ||
_this2.processLine(u); | ||
}); | ||
@@ -194,3 +213,3 @@ } | ||
return Base; | ||
}(); | ||
}(_events2.default.EventEmitter); | ||
@@ -197,0 +216,0 @@ // Export base. |
{ | ||
"name": "http-auth", | ||
"description": "Node.js package for HTTP basic and digest access authentication.", | ||
"version": "2.4.5", | ||
"version": "2.4.6", | ||
"author": "Gevorg Harutyunyan (http://github.com/gevorg)", | ||
@@ -6,0 +6,0 @@ "maintainers": [ |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
43247
768