Skip to content

Commit

Permalink
Security improvement Express API Rate Limit
Browse files Browse the repository at this point in the history
  • Loading branch information
unocelli committed Oct 16, 2021
1 parent 4a489f2 commit bce95bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/api/index.js
Expand Up @@ -6,6 +6,7 @@ const fs = require('fs');
var express = require('express');
var bodyParser = require('body-parser');
var authJwt = require('./jwt-helper');
const rateLimit = require("express-rate-limit");

var prjApi = require('./projects');
var authApi = require('./auth');
Expand Down Expand Up @@ -40,6 +41,14 @@ function init(_server, _runtime) {
pluginsApi.init(runtime, authJwt.verifyToken, verifyGroups);
apiApp.use(pluginsApi.app());

const limiter = rateLimit({
windowMs: 5 * 60 * 1000, // 5 minutes
max: 100 // limit each IP to 100 requests per windowMs
});

// apply to all requests
apiApp.use(limiter);

/**
* GET Server setting data
*/
Expand Down
1 change: 1 addition & 0 deletions server/package.json
Expand Up @@ -23,6 +23,7 @@
"bluebird": "^3.5.3",
"body-parser": "^1.18.3",
"express": "4.16.4",
"express-rate-limit": "^5.5.0",
"fs-extra": "^7.0.1",
"ip": "^1.1.5",
"jsonwebtoken": "^8.5.1",
Expand Down

0 comments on commit bce95bb

Please sign in to comment.