Socket
Socket
Sign inDemoInstall

passport

Package Overview
Dependencies
2
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.1 to 0.5.0

CHANGELOG.md

5

lib/authenticator.js

@@ -20,3 +20,2 @@ /**

this._framework = null;
this._userProperty = 'user';

@@ -33,3 +32,3 @@ this.init();

this.framework(require('./framework/connect')());
this.use(new SessionStrategy(this.deserializeUser.bind(this)));
this.use(new SessionStrategy({ key: this._key }, this.deserializeUser.bind(this)));
this._sm = new SessionManager({ key: this._key }, this.serializeUser.bind(this));

@@ -133,4 +132,2 @@ };

options = options || {};
this._userProperty = options.userProperty || 'user';
return this._framework.initialize(this, options);

@@ -137,0 +134,0 @@ };

19

lib/framework/connect.js

@@ -11,5 +11,3 @@ /**

* This module provides support for using Passport with Express. It exposes
* middleware that conform to the `fn(req, res, next)` signature and extends
* Node's built-in HTTP request object with useful authentication-related
* functions.
* middleware that conform to the `fn(req, res, next)` signature.
*

@@ -21,5 +19,2 @@ * @return {Object}

// HTTP extensions.
exports.__monkeypatchNode();
return {

@@ -30,13 +25,1 @@ initialize: initialize,

};
exports.__monkeypatchNode = function() {
var http = require('http');
var IncomingMessageExt = require('../http/request');
http.IncomingMessage.prototype.login =
http.IncomingMessage.prototype.logIn = IncomingMessageExt.logIn;
http.IncomingMessage.prototype.logout =
http.IncomingMessage.prototype.logOut = IncomingMessageExt.logOut;
http.IncomingMessage.prototype.isAuthenticated = IncomingMessageExt.isAuthenticated;
http.IncomingMessage.prototype.isUnauthenticated = IncomingMessageExt.isUnauthenticated;
};

@@ -1,8 +0,1 @@

/**
* Module dependencies.
*/
//var http = require('http')
// , req = http.IncomingMessage.prototype;
var req = exports = module.exports = {};

@@ -38,6 +31,3 @@

var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
var property = this._userProperty || 'user';
var session = (options.session === undefined) ? true : options.session;

@@ -67,6 +57,3 @@

req.logOut = function() {
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
var property = this._userProperty || 'user';

@@ -86,7 +73,3 @@ this[property] = null;

req.isAuthenticated = function() {
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
var property = this._userProperty || 'user';
return (this[property]) ? true : false;

@@ -93,0 +76,0 @@ };

@@ -95,8 +95,2 @@ /**

return function authenticate(req, res, next) {
if (http.IncomingMessage.prototype.logIn
&& http.IncomingMessage.prototype.logIn !== IncomingMessageExt.logIn) {
require('../framework/connect').__monkeypatchNode();
}
// accumulator for failures from each strategy in the chain

@@ -103,0 +97,0 @@ var failures = [];

/**
* Module dependencies.
*/
var IncomingMessageExt = require('../http/request');
/**
* Passport initialization.

@@ -42,15 +48,22 @@ *

*/
module.exports = function initialize(passport) {
module.exports = function initialize(passport, options) {
options = options || {};
return function initialize(req, res, next) {
req.login =
req.logIn = IncomingMessageExt.logIn;
req.logout =
req.logOut = IncomingMessageExt.logOut;
req.isAuthenticated = IncomingMessageExt.isAuthenticated;
req.isUnauthenticated = IncomingMessageExt.isUnauthenticated;
if (options.userProperty) {
req._userProperty = options.userProperty;
}
req._passport = {};
req._passport.instance = passport;
if (req.session && req.session[passport._key]) {
// load data from existing session
req._passport.session = req.session[passport._key];
}
next();
};
};

@@ -18,10 +18,10 @@ function SessionManager(options, serializeUser) {

}
if (!req._passport.session) {
req._passport.session = {};
}
req._passport.session.user = obj;
// TODO: Error if session isn't available here.
if (!req.session) {
req.session = {};
}
req.session[self._key] = req._passport.session;
if (!req.session[self._key]) {
req.session[self._key] = {};
}
req.session[self._key].user = obj;
cb();

@@ -32,5 +32,6 @@ });

SessionManager.prototype.logOut = function(req, cb) {
if (req._passport && req._passport.session) {
delete req._passport.session.user;
if (req.session && req.session[this._key]) {
delete req.session[this._key].user;
}
cb && cb();

@@ -37,0 +38,0 @@ }

@@ -23,2 +23,3 @@ /**

this.name = 'session';
this._key = options.key || 'passport';
this._deserializeUser = deserializeUser;

@@ -51,4 +52,4 @@ }

su;
if (req._passport.session) {
su = req._passport.session.user;
if (req.session[this._key]) {
su = req.session[this._key].user;
}

@@ -65,6 +66,5 @@

if (!user) {
delete req._passport.session.user;
delete req.session[self._key].user;
} else {
// TODO: Remove instance access
var property = req._passport.instance._userProperty || 'user';
var property = req._userProperty || 'user';
req[property] = user;

@@ -71,0 +71,0 @@ }

{
"name": "passport",
"version": "0.4.1",
"version": "0.5.0",
"description": "Simple, unobtrusive authentication for Node.js.",

@@ -25,2 +25,6 @@ "keywords": [

},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/jaredhanson"
},
"license": "MIT",

@@ -27,0 +31,0 @@ "licenses": [

@@ -15,2 +15,16 @@ [![passport banner](http://cdn.auth0.com/img/passport-banner-github.png)](http://passportjs.org)

---
<p align="center">
<sup>Sponsors</sup>
<br>
<a href="https://www.loginradius.com/?utm_source=sponsership&utm_medium=github&utm_campaign=jaredhanson"><img src="https://raw.githubusercontent.com/jaredhanson/passport/master/sponsors/loginradius.png"></a><br/>
<a href="https://accounts.loginradius.com/auth.aspx?action=register?utm_source=sponsership&utm_medium=github&utm_campaign=jaredhanson">LoginRadius</a> is built for the developer community to integrate robust Authentication and Single Sign-On in just a few lines of code.<br/><a href="https://accounts.loginradius.com/auth.aspx?action=register?utm_source=sponsership&utm_medium=github&utm_campaign=jaredhanson">FREE Signup</a>
<br><br>
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=passport_js&utm_source=github"><img src="https://raw.githubusercontent.com/jaredhanson/passport/master/sponsors/workos.png"></a><br/>
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=passport_js&utm_source=github"><b>Your app, enterprise-ready.</b><br/>Start selling to enterprise customers with just a few lines of code. Add Single Sign-On (and more) in minutes instead of months.</a>
</p>
---
Status:

@@ -17,0 +31,0 @@ [![Build](https://travis-ci.org/jaredhanson/passport.svg?branch=master)](https://travis-ci.org/jaredhanson/passport)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc