mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
Compare commits
10
Commits
migrate-postgres
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0467bf8d3f | ||
|
|
7caadd6695 | ||
|
|
7ab6a828ca | ||
|
|
acbe310a4c | ||
|
|
045941a05c | ||
|
|
676c12de77 | ||
|
|
b510d18758 | ||
|
|
9ffcd9fa90 | ||
|
|
3106ae00d0 | ||
|
|
9ce161e4f3 |
No files matched your search
+1
-1
@@ -30,7 +30,7 @@
|
||||
"socket.io-client": "^4.7.1",
|
||||
"validator": "^13.15.22",
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "11.3.0",
|
||||
"vue-i18n": "11.4.14",
|
||||
"vue-router": "^4.2.4",
|
||||
"vue-toastification": "^2.0.0-rc.5",
|
||||
"vue3-lottie": "^3.2.0",
|
||||
|
||||
@@ -87,15 +87,16 @@ const handleChange = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const registerGuest = async () => {
|
||||
try {
|
||||
await api.post('/auth/register-guest')
|
||||
router.push({ name: 'map' })
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
toast.error('Something went wrong.')
|
||||
}
|
||||
}
|
||||
// Guest account currently disabled
|
||||
// const registerGuest = async () => {
|
||||
// try {
|
||||
// await api.post('/auth/register-guest')
|
||||
// router.push({ name: 'map' })
|
||||
// } catch (err) {
|
||||
// console.error(err)
|
||||
// toast.error('Something went wrong.')
|
||||
// }
|
||||
// }
|
||||
</script>
|
||||
<template>
|
||||
<!-- login page -->
|
||||
@@ -241,13 +242,13 @@ const registerGuest = async () => {
|
||||
</RouterLink></span
|
||||
>
|
||||
</p>
|
||||
<button
|
||||
<!-- <button
|
||||
id="register-guest"
|
||||
class="rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
|
||||
@click="registerGuest()"
|
||||
>
|
||||
{{ t('authform.continue_as_guest') }}
|
||||
</button>
|
||||
</button> -->
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
@@ -49,7 +49,7 @@
|
||||
"socket.io-client": "^4.7.1",
|
||||
"validator": "^13.15.22",
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "11.3.0",
|
||||
"vue-i18n": "11.4.14",
|
||||
"vue-router": "^4.2.4",
|
||||
"vue-toastification": "^2.0.0-rc.5",
|
||||
"vue3-lottie": "^3.2.0",
|
||||
@@ -74,7 +74,7 @@
|
||||
"name": "@odyssey/constants",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"zod": "^3.24.2",
|
||||
"zod": "^4.6.7",
|
||||
},
|
||||
},
|
||||
"packages/file-graph": {
|
||||
@@ -86,7 +86,7 @@
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@odyssey/file-graph": "workspace:*",
|
||||
"zod": "^3.24.2",
|
||||
"zod": "^4.6.7",
|
||||
"zod-to-json-schema": "^3.24.5",
|
||||
},
|
||||
},
|
||||
@@ -133,12 +133,13 @@
|
||||
"passport-google-oidc": "^0.1.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"rate-limiter-flexible": "^11.2.3",
|
||||
"socket.io": "^4.7.1",
|
||||
"swagger-ui-express": "^5.0.0",
|
||||
"validator": "^13.15.22",
|
||||
"winston": "^3.11.0",
|
||||
"yaml": "^2.8.3",
|
||||
"zod": "^3.24.2",
|
||||
"zod": "^4.6.7",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
@@ -169,7 +170,7 @@
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"express-handlebars": "^7.1.2",
|
||||
"mongoose": "^8.24.1",
|
||||
"zod": "^3.24.2",
|
||||
"zod": "^4.6.7",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
@@ -308,13 +309,13 @@
|
||||
|
||||
"@humanwhocodes/object-schema": ["@humanwhocodes/object-schema@2.0.3", "", {}, "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA=="],
|
||||
|
||||
"@intlify/core-base": ["@intlify/core-base@11.3.0", "", { "dependencies": { "@intlify/devtools-types": "11.3.0", "@intlify/message-compiler": "11.3.0", "@intlify/shared": "11.3.0" } }, "sha512-NNX5jIwF4TJBe7RtSKDMOA6JD9mp2mRcBHAwt2X+Q8PvnZub0yj5YYXlFu2AcESdgQpEv/5Yx2uOCV/yh7YkZg=="],
|
||||
"@intlify/core-base": ["@intlify/core-base@11.4.14", "", { "dependencies": { "@intlify/devtools-types": "11.4.14", "@intlify/message-compiler": "11.4.14", "@intlify/shared": "11.4.14" } }, "sha512-Lox+qRGBLnEYfNz4iajqKpw1zuvSAWl4PtzEk654bEM+0NT1GBy9AbOecxzSh7krsyqn9mGKhgmvtuyBsqS6oQ=="],
|
||||
|
||||
"@intlify/devtools-types": ["@intlify/devtools-types@11.3.0", "", { "dependencies": { "@intlify/core-base": "11.3.0", "@intlify/shared": "11.3.0" } }, "sha512-G9CNL4WpANWVdUjubOIIS7/D2j/0j+1KJmhBJxHilWNKr9mmt3IjFV3Hq4JoBP23uOoC5ynxz/FHZ42M+YxfGw=="],
|
||||
"@intlify/devtools-types": ["@intlify/devtools-types@11.4.14", "", { "dependencies": { "@intlify/core-base": "11.4.14", "@intlify/shared": "11.4.14" } }, "sha512-EQHRYveQg6yHQ51kePfsFyaW2WW+0hk3FdVxSpLDyuKtqFtsRFoyQR2QzASZPmY767ujs9ipuxc2DiGJARkuiQ=="],
|
||||
|
||||
"@intlify/message-compiler": ["@intlify/message-compiler@11.3.0", "", { "dependencies": { "@intlify/shared": "11.3.0", "source-map-js": "^1.0.2" } }, "sha512-RAJp3TMsqohg/Wa7bVF3cChRhecSYBLrTCQSj7j0UtWVFLP+6iEJoE2zb7GU5fp+fmG5kCbUdzhmlAUCWXiUJw=="],
|
||||
"@intlify/message-compiler": ["@intlify/message-compiler@11.4.14", "", { "dependencies": { "@intlify/shared": "11.4.14", "source-map-js": "^1.0.2" } }, "sha512-y79GatHfMhN672Vooxw0v6mgX/vclFHggO1ENL6aH/QubLXiV529WXu/+FhVUbYF+HLTeDDkQpmnpfvSJddBCg=="],
|
||||
|
||||
"@intlify/shared": ["@intlify/shared@11.3.0", "", {}, "sha512-LC6P/uay7rXL5zZ5+5iRJfLs/iUN8apu9tm8YqQVmW3Uq3X4A0dOFUIDuAmB7gAC29wTHOS3EiN/IosNSz0eNQ=="],
|
||||
"@intlify/shared": ["@intlify/shared@11.4.14", "", {}, "sha512-f8zSlPs4+Yd9za3CPQfW9OHxAJBOeRQzB/hhOhkbGA7hlqWk0W0bUtSV/LmyrGNwdl8JriBnFtJqZyF140bjGg=="],
|
||||
|
||||
"@isaacs/cliui": ["@isaacs/cliui@8.0.2", "", { "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" } }, "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA=="],
|
||||
|
||||
@@ -1604,6 +1605,8 @@
|
||||
|
||||
"range-parser": ["range-parser@1.2.1", "", {}, "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="],
|
||||
|
||||
"rate-limiter-flexible": ["rate-limiter-flexible@11.2.3", "", {}, "sha512-w4HX4toAsEbu1VksOauZwI9d6URb6/4WqJJ5Hg1bESihMt2KJfQ2iTwvDkhIg+y2HetLh65DGu/8xIkUz/xNPA=="],
|
||||
|
||||
"raw-body": ["raw-body@2.5.3", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.4.24", "unpipe": "~1.0.0" } }, "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA=="],
|
||||
|
||||
"react-is": ["react-is@17.0.2", "", {}, "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="],
|
||||
@@ -1884,7 +1887,7 @@
|
||||
|
||||
"vue-eslint-parser": ["vue-eslint-parser@9.4.3", "", { "dependencies": { "debug": "^4.3.4", "eslint-scope": "^7.1.1", "eslint-visitor-keys": "^3.3.0", "espree": "^9.3.1", "esquery": "^1.4.0", "lodash": "^4.17.21", "semver": "^7.3.6" }, "peerDependencies": { "eslint": ">=6.0.0" } }, "sha512-2rYRLWlIpaiN8xbPiDyXZXRgLGOtWxERV7ND5fFAv5qo1D2N9Fu9MNajBNc6o13lZ+24DAWCkQCvj4klgmcITg=="],
|
||||
|
||||
"vue-i18n": ["vue-i18n@11.3.0", "", { "dependencies": { "@intlify/core-base": "11.3.0", "@intlify/devtools-types": "11.3.0", "@intlify/shared": "11.3.0", "@vue/devtools-api": "^6.5.0" }, "peerDependencies": { "vue": "^3.0.0" } }, "sha512-1J+xDfDJTLhDxElkd3+XUhT7FYSZd2b8pa7IRKGxhWH/8yt6PTvi3xmWhGwhYT5EaXdatui11pF2R6tL73/zPA=="],
|
||||
"vue-i18n": ["vue-i18n@11.4.14", "", { "dependencies": { "@intlify/core-base": "11.4.14", "@intlify/devtools-types": "11.4.14", "@intlify/shared": "11.4.14", "@vue/devtools-api": "^6.5.0" }, "peerDependencies": { "vue": "^3.0.0" } }, "sha512-oRFZtQjRDRQtfxu7tFlsZlnCa5gPkg/KX89kJDKdC9bz4GIYgo3cAMaD0XFeUx/WHuKoVbDMRTIo9Hvg67HnPw=="],
|
||||
|
||||
"vue-router": ["vue-router@4.6.4", "", { "dependencies": { "@vue/devtools-api": "^6.6.4" }, "peerDependencies": { "vue": "^3.5.0" } }, "sha512-Hz9q5sa33Yhduglwz6g9skT8OBPii+4bFn88w6J+J4MfEo4KRRpmiNG/hHHkdbRFlLBOqxN8y8gf2Fb0MTUgVg=="],
|
||||
|
||||
@@ -1952,7 +1955,7 @@
|
||||
|
||||
"yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],
|
||||
|
||||
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
"zod": ["zod@4.6.7", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
|
||||
|
||||
"zod-to-json-schema": ["zod-to-json-schema@3.25.2", "", { "peerDependencies": { "zod": "^3.25.28 || ^4" } }, "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA=="],
|
||||
|
||||
@@ -1962,6 +1965,8 @@
|
||||
|
||||
"@eslint/eslintrc/globals": ["globals@13.24.0", "", { "dependencies": { "type-fest": "^0.20.2" } }, "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ=="],
|
||||
|
||||
"@formbricks/js/zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@isaacs/cliui/string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="],
|
||||
|
||||
"@isaacs/cliui/strip-ansi": ["strip-ansi@7.2.0", "", { "dependencies": { "ansi-regex": "^6.2.2" } }, "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w=="],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:v3.6.9
|
||||
restart: always
|
||||
ports:
|
||||
- 8000:8000
|
||||
- 8080:8080
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
version: '3'
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:v3.6.9
|
||||
@@ -22,7 +21,6 @@ services:
|
||||
|
||||
db:
|
||||
image: mongo:6
|
||||
restart: always
|
||||
networks:
|
||||
- internal
|
||||
ports:
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
".": "./index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^4.6.7"
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@odyssey/file-graph": "workspace:*",
|
||||
"zod": "^3.24.2",
|
||||
"zod": "^4.6.7",
|
||||
"zod-to-json-schema": "^3.24.5"
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -38,12 +38,13 @@
|
||||
"passport-google-oidc": "^0.1.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"rate-limiter-flexible": "^11.2.3",
|
||||
"socket.io": "^4.7.1",
|
||||
"swagger-ui-express": "^5.0.0",
|
||||
"validator": "^13.15.22",
|
||||
"winston": "^3.11.0",
|
||||
"yaml": "^2.8.3",
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^4.6.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
|
||||
@@ -73,7 +73,7 @@ async function recordLogin(req: Request, success: boolean, message: string) {
|
||||
|
||||
router.post('/register', authenticateRateLimit, registerValidators, register)
|
||||
|
||||
router.post('/register-guest', authenticateRateLimit, registerGuest)
|
||||
// router.post('/register-guest', authenticateRateLimit, registerGuest)
|
||||
|
||||
router.post('/logout', logout)
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import rateLimit from 'express-rate-limit'
|
||||
import type { Options } from 'express-rate-limit'
|
||||
import type { Request, Response, NextFunction } from 'express'
|
||||
import { RateLimiterMemory } from 'rate-limiter-flexible'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { LoginAttempt } from '@odyssey/models'
|
||||
import config from '../config.js'
|
||||
import logger from '../utils/logger.js'
|
||||
import { middleware } from '../trpc.js'
|
||||
|
||||
function createRateLimiter(options: Partial<Options>) {
|
||||
if (config.testing.enabled) {
|
||||
@@ -22,13 +25,32 @@ export const authenticateRateLimit = createRateLimiter({
|
||||
max: 5,
|
||||
})
|
||||
|
||||
export const sessionRateLimit = createRateLimiter({
|
||||
windowMs: 10 * 1000,
|
||||
max: 1,
|
||||
keyGenerator: (req: Request) => {
|
||||
return req.user ? (req.user as any)._id : req.ip || ''
|
||||
},
|
||||
export function trpcRateLimit({
|
||||
points,
|
||||
duration,
|
||||
}: {
|
||||
points: number
|
||||
duration: number
|
||||
}) {
|
||||
const limiter = new RateLimiterMemory({ points, duration })
|
||||
return middleware(async (opts) => {
|
||||
if (config.testing.enabled) {
|
||||
return opts.next()
|
||||
}
|
||||
const key = opts.ctx.user?.id ?? opts.ctx.ip ?? ''
|
||||
try {
|
||||
await limiter.consume(key)
|
||||
} catch {
|
||||
throw new TRPCError({
|
||||
code: 'TOO_MANY_REQUESTS',
|
||||
message: 'Too many requests. Please try again later.',
|
||||
})
|
||||
}
|
||||
return opts.next()
|
||||
})
|
||||
}
|
||||
|
||||
export const sessionRateLimit = trpcRateLimit({ points: 3, duration: 60 })
|
||||
|
||||
export async function rateLimitByAccount(
|
||||
req: Request,
|
||||
|
||||
@@ -8,6 +8,7 @@ import config from '../config.js'
|
||||
import { protectedProcedure, router } from '../trpc.js'
|
||||
import { questManager } from '../models/quest.js'
|
||||
import { genJWT } from '../utils/auth'
|
||||
import { sessionRateLimit } from '../middleware/rateLimiter.js'
|
||||
|
||||
export type SessionDetail = Awaited<ReturnType<typeof sessionDetail>>
|
||||
|
||||
@@ -47,6 +48,7 @@ async function sessionDetail(session: ISession) {
|
||||
|
||||
export const sessionRouter = router({
|
||||
createSession: protectedProcedure
|
||||
.use(sessionRateLimit)
|
||||
.input(
|
||||
z.object({
|
||||
questId: z.string(),
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ const t = initTRPC.context<AppContext>().create()
|
||||
* Export reusable router and procedure helpers
|
||||
* that can be used throughout the router
|
||||
*/
|
||||
export const { router, procedure: publicProcedure } = t
|
||||
export const { router, procedure: publicProcedure, middleware } = t
|
||||
|
||||
export const protectedProcedure = publicProcedure.use(async (opts) => {
|
||||
if (opts.ctx.isAuthenticated() && !('newUser' in opts.ctx.user)) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"express-handlebars": "^7.1.2",
|
||||
"mongoose": "^8.24.1",
|
||||
"zod": "^3.24.2"
|
||||
"zod": "^4.6.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
|
||||
Reference in new issue
Block a user