A MS Sql Server store for express-brute via mssql.
via npm:
$ npm install express-brute-mssql
express-brute-msql expects a table named brute
(this may be overridden in the constructor) to exist in whatever database you're connecting to.
create table bruteschema.brute(
id nvarchar(255) primary key,
count int,
first_request datetime2,
last_request datetime2,
expires datetime2
);
var ExpressBrute = require('express-brute'),
MsSqlStore = require('express-brute-mssql');
var store = new MsSqlStore({
host: '127.0.0.1',
tableName: 'brute',
database: 'brutedb',
schemaName: 'bruteschema',
username: 'appuser',
password: 'password'
});
var bruteforce = new ExpressBrute(store);
app.post('/auth',
bruteforce.prevent, // error 403 if we hit this route too often
function (req, res, next) {
res.send('Success!');
}
);
host
MS Sql Server host name or IP addressdatabase
Database name to connect tousername
Database usernamepassword
Corresponding password, if password authentication is requiredtableName
Include to use a storage table named something other thanbrute
schemaName
Include if your storage table is in a schema other thandbo
pool
You may pass in your application'spool
instance toexpress-brute-mssql
to share connection pools or use the native bindings; if not supplied,express-brute-mssql
will spin up its own pool