Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions service/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var express = require("express");
var session = require("express-session");
var bodyParser = require("body-parser");
var path = require("path");
var csrf = require("csurf");
var rateLimit = require("express-rate-limit");

var connection = mysql.createConnection({
host: "db",
Expand All @@ -23,11 +25,23 @@ app.use(
secret: require("crypto").randomBytes(64).toString("hex"),
resave: true,
saveUninitialized: true,
cookie: { secure: true } // 쿠킀에 secure ν”Œλž˜κ·Έ μΆ”κ°€
})
);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

// CSRF 보호 미듀웨어 μΆ”κ°€
var csrfProtection = csrf({ cookie: true });
app.use(csrfProtection);

// 속도 μ œν•œ 미듀웨어 μΆ”κ°€
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15λΆ„
max: 100 // 각 IPλ‹Ή 100개의 μš”μ²­μœΌλ‘œ μ œν•œ
});
app.use(limiter);

app.get("/", function (request, response) {
response.sendFile(path.join(__dirname + "/login.html"));
});
Expand Down