feat: Redis-backed tiered rate limiting for all sensitive routes#363
feat: Redis-backed tiered rate limiting for all sensitive routes#363anika00mangla wants to merge 30 commits into
Conversation
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated redis plugin to use environment variable for Redis URL and added a name option for dependency management. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated rate limiting for profile routes to moderate levels and added per-route configurations. No business logic was modified. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated rate limiting for all routes to moderate (60 req/min per user ID) to accommodate write-heavy card CRUD operations. No business logic was modified. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Added moderate rate limiting to analytics routes to prevent excessive database calls. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated rate limiting for GitHub connect routes and adjusted environment variable usage for configuration. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated rate limiting for follow routes to moderate level for specific actions. No business logic modified. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated rate limiting for public routes and refactored follow logic. Fixed duplicate route registrations and added QR code generation functionality. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Updated the CONTRIBUTING.md file to include details on rate limiting, environment configuration, and testing procedures. Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
|
@Harxhit PLZ REVIEW AND MERGE IT AND PLZ ALSO PUT ALL THE REQUIRED LABELS TOO FOR GSSOC !! THANK YOU !!🙏 |
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
|
@Harxhit plz merge this pull request !! and plz add all the required labels for gssoc : security, backend, enhancement, area: backend, difficulty: advanced |
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anikamanglaavbil@gmail.com>
|
@Harxhit ??????? ITS BEEN QUITE SOME DAYS SINCE I RAISED THIS PLEASE REVIEW IT |
CI Results — ❌ Some checks failed🖥️ Backend (❌ failure)
📱 Mobile (⏭️ skipped)
🌐 Web (⏭️ skipped)
🕐 Last updated: |
|
Thank you for the contribution. After reviewing this PR, I'm going to close it. The implementation currently does not meet the project's quality standards and contains multiple issues, including compilation errors, incorrect imports, API misuse, missing error handling, lint , typcheck and code paths that do not appear to have been tested locally. Please ensure future submissions are fully validated with the project's build, lint, and test commands before opening a PR. Once these issues are addressed and the implementation has been thoroughly reviewed, you're welcome to submit a new pull request. Thank you for your time and effort. |
Type of Change
ISSUE NUMBER #256 RESOLVED
What Changed
src/plugins/rate-limit.ts(new) — tiered rate limit plugin backed by existing Redis connectionsrc/plugins/redis.ts— added plugin name for dependency orderingsrc/app.ts— replaced old in-memory global limit with newrateLimitPluginsrc/routes/auth.ts— STRICT limits on all OAuth and auth routessrc/routes/connect.ts— STRICT on OAuth callbacks, MODERATE on status/disconnectsrc/routes/profiles.ts,cards.ts,analytics.ts,follow.ts— MODERATE limits on all mutationssrc/routes/public.ts— RELAXED limits on public reads; fixed duplicate nested route registration bugtests/rate-limit.test.ts(new) — integration tests for all three tiers usingioredis-mockpackage.json— addedioredis-mockto devDependenciesCONTRIBUTING.md— documented rate limit tiers and usageHow to Test
pnpm installthendocker compose up -d && pnpm dev:backendpnpm --filter @devcard/backend test302for first 10,429withRetry-AfterafterChecklist
pnpm -r run lintpasses).pnpm -r run typecheck).pnpm -r run test).console.logor debug statements left in the code.Screenshots / Recordings
N/A — backend-only, no UI changes.
Additional Context
Rate limit state lives in Redis so counters persist across restarts. Authenticated routes key on user ID so users behind shared IPs are never incorrectly throttled.
Labels to add:
security,backend,enhancement,area: backend,difficulty: advanced