mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Merge pull request #2657 from simong/cookie-parser
Use the cookie parser middleware
This commit is contained in:
commit
9e9207d8b6
2 changed files with 4 additions and 5 deletions
|
@ -6,6 +6,7 @@ var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
var ueberStore = require('../../db/SessionStore');
|
var ueberStore = require('../../db/SessionStore');
|
||||||
var stats = require('ep_etherpad-lite/node/stats');
|
var stats = require('ep_etherpad-lite/node/stats');
|
||||||
var sessionModule = require('express-session');
|
var sessionModule = require('express-session');
|
||||||
|
var cookieParser = require('cookie-parser');
|
||||||
|
|
||||||
//checks for basic http auth
|
//checks for basic http auth
|
||||||
exports.basicAuth = function (req, res, next) {
|
exports.basicAuth = function (req, res, next) {
|
||||||
|
@ -76,7 +77,7 @@ exports.basicAuth = function (req, res, next) {
|
||||||
Note that the process could stop already in step 3 with a redirect to login page.
|
Note that the process could stop already in step 3 with a redirect to login page.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
authorize(function (ok) {
|
authorize(function (ok) {
|
||||||
if (ok) return next();
|
if (ok) return next();
|
||||||
authenticate(function (ok) {
|
authenticate(function (ok) {
|
||||||
|
@ -121,6 +122,8 @@ exports.expressConfigure = function (hook_name, args, cb) {
|
||||||
args.app.sessionStore = exports.sessionStore;
|
args.app.sessionStore = exports.sessionStore;
|
||||||
args.app.use(sessionModule({secret: exports.secret, store: args.app.sessionStore, resave: true, saveUninitialized: true, name: 'express_sid' }));
|
args.app.use(sessionModule({secret: exports.secret, store: args.app.sessionStore, resave: true, saveUninitialized: true, name: 'express_sid' }));
|
||||||
|
|
||||||
|
args.app.use(cookieParser(settings.sessionKey, {}));
|
||||||
|
|
||||||
args.app.use(exports.basicAuth);
|
args.app.use(exports.basicAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,6 @@ var securityManager = require('./db/SecurityManager');
|
||||||
|
|
||||||
//checks for padAccess
|
//checks for padAccess
|
||||||
module.exports = function (req, res, callback) {
|
module.exports = function (req, res, callback) {
|
||||||
|
|
||||||
// FIXME: Why is this ever undefined??
|
|
||||||
if (req.cookies === undefined) req.cookies = {};
|
|
||||||
|
|
||||||
securityManager.checkAccess(req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password, function(err, accessObj) {
|
securityManager.checkAccess(req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password, function(err, accessObj) {
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue