ADDED BRUTE FORCE PREVENTION
This commit is contained in:
parent
1f63afd4a5
commit
8c4896bca3
@ -1,5 +1,6 @@
|
||||
const express = require("express");
|
||||
const session = require("express-session");
|
||||
const rateLimit = require('express-rate-limit');
|
||||
const mysql2 = require('mysql2');
|
||||
const bodyParser = require("body-parser");
|
||||
const bcrypt = require("bcrypt");
|
||||
@ -128,6 +129,14 @@ const logActivity = async (username, success, message) => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const limiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: 5, // limit each IP to 3 requests per windowMs
|
||||
message: 'Too many login attempts from this IP, please try again later.',
|
||||
});
|
||||
app.use('/login', limiter);
|
||||
|
||||
app.post('/login', [
|
||||
body('username').escape().trim().isLength({ min: 1 }).withMessage('Username must not be empty'),
|
||||
body('password').escape().trim().isLength({ min: 1 }).withMessage('Password must not be empty'),
|
||||
|
2685
package-lock.json
generated
2685
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user