Generate tokens and ids with cryptoUtils module.
Move object ID, token, and random string generation into their own module, cryptoUtils. Remove hat dependency, which was used to generate session and some other tokens, because it used non-cryptographic random number generator. Replace it with the cryptographically secure one. The result has the same format (32-character hex string, 128 bits of entropy). Remove randomstring dependency, as we already have this functionality. Add tests.
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
var express = require('express'),
|
||||
cache = require('./cache'),
|
||||
middlewares = require('./middlewares'),
|
||||
rack = require('hat').rack();
|
||||
cryptoUtils = require('./cryptoUtils');
|
||||
|
||||
var router = express.Router();
|
||||
|
||||
// creates a unique app in the cache, with a collection prefix
|
||||
function createApp(req, res) {
|
||||
var appId = rack();
|
||||
var appId = cryptoUtils.randomHexString(32);
|
||||
cache.apps[appId] = {
|
||||
'collectionPrefix': appId + '_',
|
||||
'masterKey': 'master'
|
||||
@@ -70,4 +70,4 @@ router.post('/rest_configure_app',
|
||||
|
||||
module.exports = {
|
||||
router: router
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user