Replaced Express-Brute store from Mongo to Mongoose

This commit is contained in:
NGPixel 2016-10-17 19:22:28 -04:00
parent 94fe4bbf14
commit 2cf8f2c247
4 changed files with 23 additions and 8 deletions

View File

@ -12,7 +12,6 @@ env:
global: global:
- CXX=g++-4.8 - CXX=g++-4.8
- secure: VCgscCCKhvHu0tW8e3jo6wydckE6jDkEfC2Zd5aSZytYAex05qahU45cmksqMIT1uBCcC4CKRK4caoKac/+818EyKBTV+vAL74cMMc8NeLNVY2m50+ohu8GYu+ByIffttK7cnXN7xIzyuK4csI7qz84jxLW0KYgYQ+6SPbUG3Hy6gr0P0CztNmAFfyhTam4OKSIiXyvQZW0fZoSruOpUYS5pxvCBi4AxpRY8+6IxCL8xYqF49P0l28nn0C/NYUklwag6l4JF32PrcLAU5S+NIXXgJX499cZO4C2m2GljJeolbvGue3ZEtadv5NkmQuFQ1WGb5aURHPkll0hXsWKxT0bH9P1a4Gt1h/J885acWG4U6QZA1Zds/Z4ymNeLA0MzzoAaDK1q8sRglhDJnZYb4Zm5jy7ZA3vFwb+zcGaOT//pCVpcsZINRnd0Qu9LC5NKPrfmyFAAMAXDdo78BEnwryUviWP5976JZmQAfDIWvmGGTs5i1yjiTRi+NVgH0YpfxtI9MTEJo++r5/zNH/jewxj1D8esaamphp6mQvxvpl388veQDw3REUZQ49muzrdK2YYmVRkzLfH2uMsHInN3WqEl3/mTpH76u0nlxMF6HlrVdgB2UNPjlXbSooWXLfdAw98NpCZ7BAFcCcT8Oa9cYw+40rJrdfem5J2EimG5ltw= - secure: VCgscCCKhvHu0tW8e3jo6wydckE6jDkEfC2Zd5aSZytYAex05qahU45cmksqMIT1uBCcC4CKRK4caoKac/+818EyKBTV+vAL74cMMc8NeLNVY2m50+ohu8GYu+ByIffttK7cnXN7xIzyuK4csI7qz84jxLW0KYgYQ+6SPbUG3Hy6gr0P0CztNmAFfyhTam4OKSIiXyvQZW0fZoSruOpUYS5pxvCBi4AxpRY8+6IxCL8xYqF49P0l28nn0C/NYUkl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DHwOBbSLa+X/sBomyONgBAve6roqtiQgZ3T92SycyjW06vhG7akC+yAKnAKVL+JdWWvg4qPhppKRAa57/5Se9GlAthSXvhfGvkaKtA4IUq9Jr7FksF4f+tCkSfNeJBYnlV+c/oBY7ZZ9gMUslXuDtv8Dbgp2aa4ELeA9R0U+5Ac42JzzbfojwOaLpEvFYs2cdZybOPlUq/EO/rx2Oxi9Xk2oPL4UW9xV5ZlwYmCw/rXpzSWo4dl4i0tEPN+5ZPtgQGz5pIBeI0LGGvEhCya/Tg+Xc9Bd7/0Ox7cLgNk0vrTEVjW+Z/b3XMhVwVlwmTuVM5wylzaZRcc=
cache: cache:
directories: directories:

View File

@ -2,17 +2,13 @@ var express = require('express');
var router = express.Router(); var router = express.Router();
var passport = require('passport'); var passport = require('passport');
var ExpressBrute = require('express-brute'); var ExpressBrute = require('express-brute');
var ExpressBruteMongoStore = require('express-brute-mongo'); var ExpressBruteMongooseStore = require('express-brute-mongoose');
var moment = require('moment'); var moment = require('moment');
/** /**
* Setup Express-Brute * Setup Express-Brute
*/ */
var EBstore = new ExpressBruteMongoStore((ready) => { var EBstore = new ExpressBruteMongooseStore(db.Bruteforce);
db.onReady.then(() => {
ready(db.connection.collection('bruteforce-store'));
});
});
var bruteforce = new ExpressBrute(EBstore, { var bruteforce = new ExpressBrute(EBstore, {
freeRetries: 5, freeRetries: 5,
minWait: 60 * 1000, minWait: 60 * 1000,

20
models/bruteforce.js Normal file
View File

@ -0,0 +1,20 @@
"use strict";
const modb = require('mongoose');
/**
* BruteForce schema
*
* @type {<Mongoose.Schema>}
*/
var bruteForceSchema = modb.Schema({
_id: { type: String, index: 1 },
data: {
count: Number,
lastRequest: Date,
firstRequest: Date
},
expires: { type: Date, index: { expires: '1d' } }
});
module.exports = modb.model('Bruteforce', bruteForceSchema);

View File

@ -46,7 +46,7 @@
"cron": "^1.1.1", "cron": "^1.1.1",
"express": "^4.14.0", "express": "^4.14.0",
"express-brute": "^1.0.0", "express-brute": "^1.0.0",
"express-brute-mongo": "^0.1.0", "express-brute-mongoose": "0.0.6",
"express-session": "^1.14.1", "express-session": "^1.14.1",
"farmhash": "^1.2.1", "farmhash": "^1.2.1",
"file-type": "^3.8.0", "file-type": "^3.8.0",