@openneuro/server 4.44.4 → 4.44.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.44.
|
|
3
|
+
"version": "4.44.5",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@elastic/elasticsearch": "8.13.1",
|
|
22
22
|
"@graphql-tools/schema": "^10.0.0",
|
|
23
23
|
"@keyv/redis": "^4.5.0",
|
|
24
|
-
"@openneuro/search": "^4.44.
|
|
25
|
-
"@sentry/node": "^
|
|
26
|
-
"@sentry/profiling-node": "^
|
|
24
|
+
"@openneuro/search": "^4.44.5",
|
|
25
|
+
"@sentry/node": "^10.37.0",
|
|
26
|
+
"@sentry/profiling-node": "^10.37.0",
|
|
27
27
|
"base64url": "^3.0.0",
|
|
28
28
|
"cookie-parser": "^1.4.6",
|
|
29
29
|
"cors": "^2.8.5",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "337fffde4c5ea0c3f6f26f7f93d5357197036aa7"
|
|
93
93
|
}
|
|
@@ -2,6 +2,7 @@ import passport from "passport"
|
|
|
2
2
|
import refresh from "passport-oauth2-refresh"
|
|
3
3
|
import jwt from "jsonwebtoken"
|
|
4
4
|
import * as Sentry from "@sentry/node"
|
|
5
|
+
import type { Request } from "express"
|
|
5
6
|
import { decrypt } from "./crypto"
|
|
6
7
|
import User from "../../models/user"
|
|
7
8
|
import config from "../../config"
|
|
@@ -175,6 +176,19 @@ const refreshToken = async (jwt) => {
|
|
|
175
176
|
// Shared options for Express response.cookie()
|
|
176
177
|
const cookieOptions = { sameSite: "Lax" }
|
|
177
178
|
|
|
179
|
+
// Obtain client IP address from request, considering possible proxies
|
|
180
|
+
function getClientIp(req: Request): string | undefined {
|
|
181
|
+
const forwardedForHeader = req.headers["x-forwarded-for"]
|
|
182
|
+
if (forwardedForHeader) {
|
|
183
|
+
const ips = Array.isArray(forwardedForHeader)
|
|
184
|
+
? forwardedForHeader
|
|
185
|
+
: forwardedForHeader.split(",")
|
|
186
|
+
const clientIp = ips[0].trim()
|
|
187
|
+
return clientIp
|
|
188
|
+
}
|
|
189
|
+
return req.socket.remoteAddress || undefined
|
|
190
|
+
}
|
|
191
|
+
|
|
178
192
|
// attach user obj to request based on jwt
|
|
179
193
|
// if user does not exist, continue
|
|
180
194
|
export const authenticate = (req, res, next) => {
|
|
@@ -192,7 +206,7 @@ export const authenticate = (req, res, next) => {
|
|
|
192
206
|
if (user) {
|
|
193
207
|
Sentry.setUser({
|
|
194
208
|
id: user.id,
|
|
195
|
-
ip_address: req
|
|
209
|
+
ip_address: getClientIp(req),
|
|
196
210
|
})
|
|
197
211
|
}
|
|
198
212
|
Sentry.setContext("request_headers", {
|