Merge develop-enterprise into develop (Entra ID SSO)#3032
Merge develop-enterprise into develop (Entra ID SSO)#3032HarshP4585 wants to merge 8 commits intodevelopfrom
Conversation
| }); | ||
| router.post("/login", loginLimiter, loginUser); | ||
|
|
||
| router.post("/login-microsoft", loginUserWithMicrosoft); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
In general, each authentication or authorization endpoint that may trigger expensive operations (database queries, password processing, external IdP calls) should be protected with an appropriate rate‑limiting middleware. This is already done for /login via a dedicated loginLimiter and for other sensitive endpoints via authLimiter. The fix is to ensure /login-microsoft is also wrapped with a rate limiter.
The most consistent and least intrusive fix is to reuse an existing limiter (authLimiter or loginLimiter) rather than inventing a new pattern. Since /login-microsoft is a login endpoint, reusing the same loginLimiter used for /login makes sense and preserves behavior: both login routes will now share the same “5 requests per minute per IP” policy and error message. Technically, this only requires updating the route definition on line 136 to insert loginLimiter as middleware. No new imports or helper functions are needed because loginLimiter is declared just above and rateLimit is already imported.
Concretely, in Servers/routes/user.route.ts, modify the /login-microsoft route so that:
router.post("/login-microsoft", loginLimiter, loginUserWithMicrosoft);replaces the original line router.post("/login-microsoft", loginUserWithMicrosoft);. No other lines need to change.
| @@ -133,7 +133,7 @@ | ||
| }); | ||
| router.post("/login", loginLimiter, loginUser); | ||
|
|
||
| router.post("/login-microsoft", loginUserWithMicrosoft); | ||
| router.post("/login-microsoft", loginLimiter, loginUserWithMicrosoft); | ||
|
|
||
| router.post("/refresh-token", authLimiter, refreshAccessToken); | ||
|
|
Describe your changes
Write your issue number after "Fixes "
Enter the corresponding issue number after "Fixes #"
Please ensure all items are checked off before requesting a review: