mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(login): add request ip to the failed request log (#714)
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@supercharge/request-ip": "^1.1.2",
|
||||||
"@svgr/webpack": "^5.5.0",
|
"@svgr/webpack": "^5.5.0",
|
||||||
"ace-builds": "^1.4.12",
|
"ace-builds": "^1.4.12",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
@@ -22,6 +22,7 @@ import { getAppVersion } from './utils/appVersion';
|
|||||||
import SlackAgent from './lib/notifications/agents/slack';
|
import SlackAgent from './lib/notifications/agents/slack';
|
||||||
import PushoverAgent from './lib/notifications/agents/pushover';
|
import PushoverAgent from './lib/notifications/agents/pushover';
|
||||||
import WebhookAgent from './lib/notifications/agents/webhook';
|
import WebhookAgent from './lib/notifications/agents/webhook';
|
||||||
|
import { getClientIp } from '@supercharge/request-ip';
|
||||||
|
|
||||||
const API_SPEC_PATH = path.join(__dirname, '../overseerr-api.yml');
|
const API_SPEC_PATH = path.join(__dirname, '../overseerr-api.yml');
|
||||||
|
|
||||||
@@ -62,6 +63,21 @@ app
|
|||||||
server.use(cookieParser());
|
server.use(cookieParser());
|
||||||
server.use(bodyParser.json());
|
server.use(bodyParser.json());
|
||||||
server.use(bodyParser.urlencoded({ extended: true }));
|
server.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
server.use((req, res, next) => {
|
||||||
|
try {
|
||||||
|
const descriptor = Object.getOwnPropertyDescriptor(req, 'ip');
|
||||||
|
if (descriptor?.writable === true) {
|
||||||
|
req.ip = getClientIp(req) ?? '';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('Failed to attach the ip to the request', {
|
||||||
|
label: 'Middleware',
|
||||||
|
message: e.message,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Setup sessions
|
// Setup sessions
|
||||||
const sessionRespository = getRepository(Session);
|
const sessionRespository = getRepository(Session);
|
||||||
|
@@ -151,6 +151,7 @@ authRoutes.post('/local', async (req, res, next) => {
|
|||||||
logger.info('Failed login attempt from user with incorrect credentials', {
|
logger.info('Failed login attempt from user with incorrect credentials', {
|
||||||
label: 'Auth',
|
label: 'Auth',
|
||||||
account: {
|
account: {
|
||||||
|
ip: req.ip,
|
||||||
email: body.email,
|
email: body.email,
|
||||||
password: '__REDACTED__',
|
password: '__REDACTED__',
|
||||||
},
|
},
|
||||||
|
@@ -1806,6 +1806,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.2.tgz#9390a8127c0dcba61ebd7fdcc748655e191bdd68"
|
resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.2.tgz#9390a8127c0dcba61ebd7fdcc748655e191bdd68"
|
||||||
integrity sha512-/5O7Fq6Vnv8L6ucmPjaWbVG1XkP4FO+w5glqfkIsq3Xw4oyNAdJddbnYodNDAfjVUvo/rrSCTom4kAND7T1o5Q==
|
integrity sha512-/5O7Fq6Vnv8L6ucmPjaWbVG1XkP4FO+w5glqfkIsq3Xw4oyNAdJddbnYodNDAfjVUvo/rrSCTom4kAND7T1o5Q==
|
||||||
|
|
||||||
|
"@supercharge/request-ip@^1.1.2":
|
||||||
|
version "1.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@supercharge/request-ip/-/request-ip-1.1.2.tgz#be9083aa50d3c6fc200f3ed5919e0b9c13fc8842"
|
||||||
|
integrity sha512-mtryG/uiSIVT0ga8A/F9hNEuBSbDxW7/m9PEtxIHqdkE/vr766m17mtLPhrXA4q4T+Qw44+33mg3Rtkl7o+OvQ==
|
||||||
|
|
||||||
"@svgr/babel-plugin-add-jsx-attribute@^5.4.0":
|
"@svgr/babel-plugin-add-jsx-attribute@^5.4.0":
|
||||||
version "5.4.0"
|
version "5.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-5.4.0.tgz#81ef61947bb268eb9d50523446f9c638fb355906"
|
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-5.4.0.tgz#81ef61947bb268eb9d50523446f9c638fb355906"
|
||||||
|
Reference in New Issue
Block a user