express-auth-negotiate
Version:
Express middleware to handle negotiate authentication
32 lines (22 loc) • 777 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _httpErrors = require('http-errors');
var _httpErrors2 = _interopRequireDefault(_httpErrors);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function () {
return function (req, res, next) {
var auth = req.get('authorization');
if (!auth) {
return res.status(401).set('WWW-Authenticate', 'Negotiate').end();
}
if (auth.lastIndexOf('Negotiate') !== 0) {
return next((0, _httpErrors2.default)(400, 'Malformed authentication token ' + auth));
}
req.auth = req.auth || {};
req.auth.token = auth.substring('Negotiate '.length);
next();
};
};
//# sourceMappingURL=index.js.map