From 4c37a93b602c20c5cf12f704b86723597f0f687e Mon Sep 17 00:00:00 2001 From: bLue Date: Sat, 27 Jul 2024 22:18:40 +0800 Subject: [PATCH] feat: change csrf cookie path and default socket.io path --- package-lock.json | 41 ++++++++++++------- package.json | 1 + src/config/config.default.ts | 3 ++ .../socket-io/src/config/config.default.ts | 1 + 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 71c4931..82ab96a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "egg-alinode": "^2.0.1", "egg-redis": "^2.4.0", "egg-scripts": "^2.10.0", + "egg-security": "^2.11.0", "egg-sequelize": "^5.2.1", "egg-session-redis": "^2.1.0", "egg-socket.io": "^4.1.6", @@ -6051,9 +6052,9 @@ } }, "node_modules/egg-security": { - "version": "2.7.1", - "resolved": "https://registry.npmmirror.com/egg-security/download/egg-security-2.7.1.tgz?cache=0&sync_timestamp=1573702940552&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fegg-security%2Fdownload%2Fegg-security-2.7.1.tgz", - "integrity": "sha1-S2JRMgPoGN3aZ6w9HMMTx2Snqbc=", + "version": "2.11.0", + "resolved": "https://registry.npmmirror.com/egg-security/-/egg-security-2.11.0.tgz", + "integrity": "sha512-htXi+R5Ik8/oKSy55LzmpFDzrzxSHLpfjbDtgSMGKYGl4uNuvb3kN2h00sl1rOz3pG/LzJvZhqxW1oIBQ7leXg==", "dependencies": { "csrf": "^3.0.6", "debug": "^4.1.1", @@ -6065,7 +6066,7 @@ "koa-compose": "^4.0.0", "matcher": "^1.1.1", "methods": "^1.1.2", - "nanoid": "^2.0.1", + "nanoid": "^3.3.2", "platform": "^1.3.4", "statuses": "^1.5.0", "type-is": "^1.6.15", @@ -14540,9 +14541,21 @@ "optional": true }, "node_modules/nanoid": { - "version": "2.1.11", - "resolved": "https://registry.npmmirror.com/nanoid/download/nanoid-2.1.11.tgz", - "integrity": "sha1-7CS4p1jVkVYVMbQXagHjq08PAoA=" + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } }, "node_modules/nanomatch": { "version": "1.2.13", @@ -26974,9 +26987,9 @@ } }, "egg-security": { - "version": "2.7.1", - "resolved": "https://registry.npmmirror.com/egg-security/download/egg-security-2.7.1.tgz?cache=0&sync_timestamp=1573702940552&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fegg-security%2Fdownload%2Fegg-security-2.7.1.tgz", - "integrity": "sha1-S2JRMgPoGN3aZ6w9HMMTx2Snqbc=", + "version": "2.11.0", + "resolved": "https://registry.npmmirror.com/egg-security/-/egg-security-2.11.0.tgz", + "integrity": "sha512-htXi+R5Ik8/oKSy55LzmpFDzrzxSHLpfjbDtgSMGKYGl4uNuvb3kN2h00sl1rOz3pG/LzJvZhqxW1oIBQ7leXg==", "requires": { "csrf": "^3.0.6", "debug": "^4.1.1", @@ -26988,7 +27001,7 @@ "koa-compose": "^4.0.0", "matcher": "^1.1.1", "methods": "^1.1.2", - "nanoid": "^2.0.1", + "nanoid": "^3.3.2", "platform": "^1.3.4", "statuses": "^1.5.0", "type-is": "^1.6.15", @@ -33837,9 +33850,9 @@ "optional": true }, "nanoid": { - "version": "2.1.11", - "resolved": "https://registry.npmmirror.com/nanoid/download/nanoid-2.1.11.tgz", - "integrity": "sha1-7CS4p1jVkVYVMbQXagHjq08PAoA=" + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==" }, "nanomatch": { "version": "1.2.13", diff --git a/package.json b/package.json index d141e78..952af4e 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "egg-alinode": "^2.0.1", "egg-redis": "^2.4.0", "egg-scripts": "^2.10.0", + "egg-security": "^2.11.0", "egg-sequelize": "^5.2.1", "egg-session-redis": "^2.1.0", "egg-socket.io": "^4.1.6", diff --git a/src/config/config.default.ts b/src/config/config.default.ts index 8965bdf..25955c5 100644 --- a/src/config/config.default.ts +++ b/src/config/config.default.ts @@ -27,6 +27,9 @@ export default (appInfo: EggAppInfo) => { config.security = { csrf: { enable: false, + cookieOptions: { + path: '/onlinejudge3/', + }, }, }; diff --git a/src/sub-app/socket-io/src/config/config.default.ts b/src/sub-app/socket-io/src/config/config.default.ts index d730d7e..77604cb 100644 --- a/src/sub-app/socket-io/src/config/config.default.ts +++ b/src/sub-app/socket-io/src/config/config.default.ts @@ -61,6 +61,7 @@ export default (appInfo: EggAppInfo) => { }; config.io = { + path: '/onlinejudge3/socket.io', init: {}, namespace: { '/': {