http-auth
Version:
Node.js package for HTTP basic and digest access authentication.
36 lines (28 loc) • 844 B
JavaScript
// Generated by CoffeeScript 1.8.0
(function() {
var HttpStrategy, passport, util;
passport = require('passport');
util = require('util');
HttpStrategy = function(authentication) {
this.name = 'http';
this.authentication = authentication;
return passport.Strategy.call(this);
};
util.inherits(HttpStrategy, passport.Strategy);
HttpStrategy.prototype.authenticate = function(req) {
var self;
self = this;
return this.authentication.isAuthenticated(req, function(result) {
var header;
if (!result.user) {
header = self.authentication.generateHeader(result);
return self.fail(header);
} else {
return self.success(result.user);
}
});
};
module.exports = function(authentication) {
return new HttpStrategy(authentication);
};
}).call(this);