Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rnd -> random_token
  • Loading branch information
Vitaly Puzrin committed Mar 27, 2015
1 parent 2d951d4 commit 4d97d15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/autoload/hooks/server_chain/csrf_token_check.js
Expand Up @@ -5,10 +5,10 @@
'use strict';


module.exports = function (N) {
var createToken = require('nodeca.core/lib/random_token');

var rnd = require('../../../rnd');

module.exports = function (N) {

N.wire.before('server_chain:http:*', { priority: -55 }, function csrf_token_set(env, callback) {
// No session - skip CSRF protection.
Expand All @@ -18,7 +18,7 @@ module.exports = function (N) {
}

// Generate CSRF token if it was not yet set.
env.session.csrf = env.session.csrf || rnd();
env.session.csrf = env.session.csrf || createToken();

// Place to page injector.
env.runtime.csrf = env.session.csrf;
Expand Down
6 changes: 3 additions & 3 deletions lib/autoload/hooks/server_chain/session.js
Expand Up @@ -8,8 +8,8 @@
'use strict';


var _ = require('lodash');
var rnd = require('../../../rnd');
var _ = require('lodash');
var createToken = require('nodeca.core/lib/random_token');


// 1 hour - default TTL for new session. It's so short because of bots which
Expand Down Expand Up @@ -82,7 +82,7 @@ module.exports = function (N) {
return;
}

env.session_id = env.session_id || rnd();
env.session_id = env.session_id || createToken();
env.session_ttl = env.session_ttl || NEW_SESSION_REDIS_TTL;

N.redis.setex(
Expand Down
File renamed without changes.
13 changes: 10 additions & 3 deletions lib/system/init/bundle/utils/cached_processor.js
Expand Up @@ -35,12 +35,19 @@ var fscached = require('./fs_cached');
// NOTE: Dependencies include processed file itself


function md5(data) {
return crypto.createHash('md5').update(data).digest('hex');
}


// calculate file digest (md5), cached
//
var fileDigest = _.memoize(function (file) {
var content = '';
try { content = fs.readFileSync(file); } catch(e) {}
return crypto.createHash('md5').update(content).digest('hex');
try {
return md5(fs.readFileSync(file));
} catch(__) {}

return '';
});


Expand Down

0 comments on commit 4d97d15

Please sign in to comment.