express-gateway-plugin-tookie
Advanced tools
Comparing version 1.0.0 to 1.1.0
const jsonParser = require('express').json(); | ||
const plugin = { | ||
version: '1.0.0', | ||
version: '1.1.0', | ||
policies: ['tookie'], | ||
init: function (pluginContext) { | ||
pluginContext.registerPolicy({ | ||
name: 'tookie', | ||
policy: (actionParams) => { | ||
return (req, res, next) => { | ||
if (req.method === 'POST') { | ||
jsonParser(req, res, (err) => { | ||
if (err) return next(err); | ||
return res.status(204).cookie('id_token', req.body.token, { | ||
httpOnly: true, | ||
secure: true, | ||
// The age is taken from GMT so we add +1h for our timezone. * 1000 for ms | ||
maxAge: (req.body.expires + 3600) * 1000 | ||
}).send(); | ||
}); | ||
} else { | ||
return res.status(204).clearCookie('id_token').send(); | ||
pluginContext.registerPolicy({ | ||
name: 'tookie', | ||
policy: (actionParams) => { | ||
return (req, res, next) => { | ||
if (req.method === 'POST') { | ||
jsonParser(req, res, (err) => { | ||
if (err) return next(err); | ||
return res.status(204).cookie('id_token', req.body.token, { | ||
httpOnly: true, | ||
secure: true, | ||
maxAge: (req.body.expires) * 1000 | ||
}).send(); | ||
}); | ||
} else { | ||
return res.status(204).clearCookie('id_token').send(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
} | ||
@@ -29,0 +28,0 @@ }; |
{ | ||
"name": "express-gateway-plugin-tookie", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "manifest.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8809
9
27