UNPKG

http-auth

Version:

Node.js package for HTTP basic and digest access authentication.

24 lines (18 loc) 601 B
passport = require 'passport' util = require 'util' HttpStrategy = (authentication) -> this.name = 'http' this.authentication = authentication passport.Strategy.call this util.inherits HttpStrategy, passport.Strategy HttpStrategy.prototype.authenticate = (req) -> self = this this.authentication.isAuthenticated req, (result) -> if not result.user header = self.authentication.generateHeader result self.fail header else self.success result.user # Export strategy. module.exports = (authentication) -> new HttpStrategy(authentication)