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

hapi-auth-cookie

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-auth-cookie - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

35

example/index.js
var Hapi = require('hapi');
var uuid = 1; // Use seq instead of proper unique identifiers for demo only
var users = {

@@ -57,4 +60,12 @@ john: {

request.auth.session.set(account);
return reply().redirect('/');
var sid = String(++uuid);
request.server.app.cache.set(sid, { account: account }, 0, function (err) {
if (err) {
reply(err);
}
request.auth.session.set({ sid: sid });
return reply().redirect('/');
});
};

@@ -72,2 +83,5 @@

var cache = server.cache('sessions', { expiresIn: 3 * 24 * 60 * 60 * 1000 });
server.app.cache = cache;
server.auth.strategy('session', 'cookie', {

@@ -77,3 +91,18 @@ password: 'secret',

redirectTo: '/login',
isSecure: false
isSecure: false,
validateFunc: function (session, callback) {
cache.get(session.sid, function (err, cached) {
if (err) {
return callback(err, false);
}
if (!cached) {
return callback(null, false);
}
return callback(null, true, cached.item.account)
})
}
});

@@ -80,0 +109,0 @@

@@ -19,2 +19,7 @@ // Load modules

exports.register.attributes = {
pkg: require('../package.json')
};
internals.implementation = function (server, options) {

@@ -21,0 +26,0 @@

6

package.json
{
"name": "hapi-auth-cookie",
"description": "Cookie authentication plugin",
"version": "1.0.3",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",
"version": "1.1.0",
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)",
"repository": "git://github.com/spumko/hapi-auth-cookie",

@@ -26,3 +26,3 @@ "main": "index",

"devDependencies": {
"hapi": "5.x.x",
"hapi": "6.x.x",
"lab": "3.x.x"

@@ -29,0 +29,0 @@ },

@@ -27,7 +27,7 @@ // Load modules

server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -64,4 +64,3 @@ ttl: 60 * 1000,

return reply('resource');
},
config: { auth: true }
}
});

@@ -74,3 +73,3 @@

return reply('logged-out');
}, config: { auth: true }
}
});

@@ -143,7 +142,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -179,4 +178,3 @@ ttl: 60 * 1000,

return reply('resource');
},
config: { auth: true }
}
});

@@ -205,7 +203,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -234,4 +232,3 @@ ttl: 60 * 1000,

return reply('resource');
},
config: { auth: true }
}
});

@@ -260,7 +257,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -290,4 +287,3 @@ ttl: 60 * 1000,

return reply('resource');
},
config: { auth: true }
}
});

@@ -315,7 +311,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -361,7 +357,7 @@ domain: 'example.com',

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -394,4 +390,3 @@ ttl: 60 * 1000,

return reply('resource');
},
config: { auth: true }
}
});

@@ -420,7 +415,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -463,7 +458,7 @@ ttl: 60 * 1000,

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -479,3 +474,3 @@ ttl: 60 * 1000,

return reply('never');
}, config: { auth: true }
}
});

@@ -495,7 +490,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie',true, {
password: 'password',

@@ -511,3 +506,3 @@ ttl: 60 * 1000,

return reply('never');
}, config: { auth: true }
}
});

@@ -527,7 +522,7 @@

var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -543,3 +538,3 @@ ttl: 60 * 1000,

return reply('never');
}, config: { auth: true }
}
});

@@ -556,10 +551,10 @@

it('does not redirect on try', function (done) {
it('redirect on try', function (done) {
var server = new Hapi.Server();
server.pack.require('../', function (err) {
server.pack.register(require('../'), function (err) {
expect(err).to.not.exist;
server.auth.strategy('default', 'cookie', {
server.auth.strategy('default', 'cookie', true, {
password: 'password',

@@ -580,4 +575,3 @@ ttl: 60 * 1000,

expect(res.result).to.equal('try');
expect(res.statusCode).to.equal(200);
expect(res.statusCode).to.equal(302);
done();

@@ -584,0 +578,0 @@ });

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