connect.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Module dependencies.
  3. */
  4. var initialize = require('../middleware/initialize')
  5. , authenticate = require('../middleware/authenticate');
  6. /**
  7. * Framework support for Connect/Express.
  8. *
  9. * This module provides support for using Passport with Express. It exposes
  10. * middleware that conform to the `fn(req, res, next)` signature and extends
  11. * Node's built-in HTTP request object with useful authentication-related
  12. * functions.
  13. *
  14. * @return {Object}
  15. * @api protected
  16. */
  17. exports = module.exports = function() {
  18. // HTTP extensions.
  19. exports.__monkeypatchNode();
  20. return {
  21. initialize: initialize,
  22. authenticate: authenticate
  23. };
  24. };
  25. exports.__monkeypatchNode = function() {
  26. var http = require('http');
  27. var IncomingMessageExt = require('../http/request');
  28. http.IncomingMessage.prototype.login =
  29. http.IncomingMessage.prototype.logIn = IncomingMessageExt.logIn;
  30. http.IncomingMessage.prototype.logout =
  31. http.IncomingMessage.prototype.logOut = IncomingMessageExt.logOut;
  32. http.IncomingMessage.prototype.isAuthenticated = IncomingMessageExt.isAuthenticated;
  33. http.IncomingMessage.prototype.isUnauthenticated = IncomingMessageExt.isUnauthenticated;
  34. };