diff --git a/app/src/components/AuthForm.vue b/app/src/components/AuthForm.vue index 563f744..4ec3f05 100644 --- a/app/src/components/AuthForm.vue +++ b/app/src/components/AuthForm.vue @@ -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.') +// } +// } @@ -241,13 +242,13 @@ const registerGuest = async () => {
- + --> diff --git a/bun.lock b/bun.lock index f93bacf..6620b14 100644 --- a/bun.lock +++ b/bun.lock @@ -133,6 +133,7 @@ "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", @@ -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=="], diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index a84538c..7f1732b 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,6 +1,7 @@ services: traefik: image: traefik:v3.6.9 + restart: always ports: - 8000:8000 - 8080:8080 diff --git a/docker-compose.yml b/docker-compose.yml index 716fc98..e138ed0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/server/package.json b/server/package.json index b42e9bc..a43f5ce 100644 --- a/server/package.json +++ b/server/package.json @@ -38,6 +38,7 @@ "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", diff --git a/server/src/api/routes/authRouter.ts b/server/src/api/routes/authRouter.ts index 0148e23..74bc788 100644 --- a/server/src/api/routes/authRouter.ts +++ b/server/src/api/routes/authRouter.ts @@ -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) diff --git a/server/src/middleware/rateLimiter.ts b/server/src/middleware/rateLimiter.ts index 43adaa5..bed6558 100644 --- a/server/src/middleware/rateLimiter.ts +++ b/server/src/middleware/rateLimiter.ts @@ -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