Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

authentication

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authentication - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

index.js

@@ -13,3 +13,1 @@ /**

exports = module.exports = new Passport();
exports.Strategy = require('./lib/strategy');

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

this._key = 'passport';
this._strategies = {};
this._userProperty = 'user';

@@ -33,65 +32,2 @@

/**
* Utilize the given `strategy` with optional `name`, overridding the strategy's
* default name.
*
* Examples:
*
* passport.use(new TwitterStrategy(...));
*
* passport.use('api', new http.BasicStrategy(...));
*
* @param {String|Strategy} name
* @param {Strategy} strategy
* @return {Authenticator} for chaining
* @api public
*/
Authenticator.prototype.use = function(name, strategy) {
if (!strategy) {
strategy = name;
name = strategy.name;
}
if (!name) { throw new Error('Authentication strategies must have a name'); }
this._strategies[name] = strategy;
return this;
};
/**
* Un-utilize the `strategy` with given `name`.
*
* In typical applications, the necessary authentication strategies are static,
* configured once and always available. As such, there is often no need to
* invoke this function.
*
* However, in certain situations, applications may need dynamically configure
* and de-configure authentication strategies. The `use()`/`unuse()`
* combination satisfies these scenarios.
*
* Examples:
*
* passport.unuse('legacy-api');
*
* @param {String} name
* @return {Authenticator} for chaining
* @api public
*/
Authenticator.prototype.unuse = function(name) {
delete this._strategies[name];
return this;
};
/**
* Return strategy with given `name`.
*
* @param {String} name
* @return {Strategy}
* @api private
*/
Authenticator.prototype.get = function(name) {
return this._strategies[name];
};
/**
* Passport's primary initialization middleware.

@@ -98,0 +34,0 @@ *

100

lib/http/request.js

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

var http = require('http')
, req = http.IncomingMessage.prototype;
, req = http.IncomingMessage.prototype;

@@ -30,31 +30,31 @@

req.login =
req.logIn = function(user, options, done) {
if (typeof options == 'function') {
done = options;
options = {};
}
options = options || {};
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
var session = (options.session === undefined) ? true : options.session;
this[property] = user;
if (session) {
if (!this._passport) { throw new Error('passport.initialize() middleware not in use'); }
if (typeof done != 'function') { throw new Error('req#login requires a callback function'); }
var self = this;
this._passport.instance.serializeUser(user, this, function(err, obj) {
if (err) { self[property] = null; return done(err); }
self._passport.session.user = obj;
done();
});
} else {
done && done();
}
};
req.logIn =
req.logInSession = function (user, options, done) {
if (typeof options == 'function') {
done = options;
options = {};
}
options = options || {};
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
var session = (options.session === undefined) ? true : options.session;
this[property] = user;
if (session) {
if (!this._passport) {
throw new Error('passport.initialize() middleware not in use');
}
if (typeof done != 'function') {
throw new Error('req#login requires a callback function');
}
this._passport.session.user = user._id;
done();
} else {
done && done();
}
};
/**

@@ -66,14 +66,14 @@ * Terminate an existing login session.

req.logout =
req.logOut = function() {
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
this[property] = null;
if (this._passport && this._passport.session) {
delete this._passport.session.user;
}
};
req.logOut = function () {
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
this[property] = null;
if (this._passport && this._passport.session) {
delete this._passport.session.user;
}
};
/**

@@ -85,9 +85,11 @@ * Test if request is authenticated.

*/
req.isAuthenticated = function() {
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
// console.log("property %s", property)
return (this[property]) ? true : false;
req.isAuthenticated = function () {
var property = 'user';
if (this._passport && this._passport.instance) {
property = this._passport.instance._userProperty || 'user';
}
if (this._passport && this._passport.session) {
return (this._passport.session.user) ? true : false;
}
return false;
};

@@ -101,4 +103,4 @@

*/
req.isUnauthenticated = function() {
return !this.isAuthenticated();
req.isUnauthenticated = function () {
return !this.isAuthenticated();
};
{
"name": "authentication",
"version": "0.0.1",
"version": "0.0.2",
"description": "just like passport",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc